@@ -232,87 +232,85 @@ alone. The next version of JavaScript will introduce a `let` keyword,
232232which works like `var` but creates a variable that is local to the
233233enclosing _block_, not the enclosing _function_.
234234
235- == Functions as values ==
235+ == Funksiyalar, dəyər kimi ==
236236
237- (((function,as value)))Function ((variable))s usually simply act as
238- names for a specific piece of the program. Such a variable is defined
239- once and never changed. This makes it easy to start confusing the
240- function and its name.
237+ (((function,as value)))Funksiya ((dəyişən))ləri əsasən müəyyən proqram
238+ hissəsi üçün ad kimi davranır. Belə dəyişən bir dəfə elan olunur ve heç vaxt
239+ dəyişilmir. Buna görə funksiyanı və onun adını qarışdırmaq çox asandır.
241240
242- (((variable,assignment)))But the two are different. A function value
243- can do all the things that other values can do—you can use it in
244- arbitrary ((expression))s, not just call it. It is possible to store a
245- function value in a new place, pass it as an argument to a function,
246- and so on. Similarly, a variable that holds a function is still just a
247- regular variable and can be assigned a new value, like so :
241+ (((variable,assignment)))Lakin bu iki anlayış fərqlidir. Funksiya
242+ dəyəri digər bütün dəyərlərin bacardığını edə bilir. Onu çağırmaqdan
243+ başqa, həm də ((ixtiyari)) ifadədə istifadə etmək olar. Funksiyanın
244+ dəyərini yeni yerdə saxlamaq, başqa funskiyaya arqument kimi ötürmək
245+ və s. olar. Funksiyanı saxlayan dəyişən eyni zamanda həm də adi bir
246+ dəyişən olduğu üçün ona aşağıdakı kimi yeni dəyər mənimsətmək olar :
248247
249248// test: no
250249
251250[source,javascript]
252251----
253- var launchMissiles = function(value) {
254- missileSystem.launch("now ");
252+ var raketleriIsheSal = function(value) {
253+ raketSistemi.isheSal("indi ");
255254};
256- if (safeMode )
257- launchMissiles = function(value) {/* do nothing */};
255+ if (tehlukesiz rejim )
256+ raketleriIsheSal = function(value) {/* heç nə etmə */};
258257----
259258
260- (((function,higher-order)))In
261- link:05_higher_order.html#higher_order[Chapter 5], we will discuss the
262- wonderful things that can be done by passing around function values to
263- other functions .
259+ (((function,higher-order)))
260+ link:05_higher_order.html#higher_order[Fəsil 5] -də funksiya dəyərini
261+ başqa funksiyalara ötürməklə necə möhtəşəm nəticələr ala biləyəcimizi
262+ müzakirə edəcəyik .
264263
265- == Declaration notation ==
264+ == Elan qaydası ==
266265
267266(((syntax)))(((square example)))(((function
268- keyword)))(((function,definition)))(((function,declaration)))There is
269- a slightly shorter way to say “++var square = function…++”. The
270- `function` keyword can also be used at the start of a statement, as in
271- the following:
267+ keyword)))(((function,definition)))(((function,declaration)))
268+ “++var kvadrat = function…++” kimi yazmaqdan daha qısa üsul var.
269+ `function` açar sözü aşağıdakı nümunədəki kimi bəyanatın ( statement)
270+ əvvəlində də gələ bilər.
272271
273272[source,javascript]
274273----
275- function square (x) {
274+ function kvadrat (x) {
276275 return x * x;
277276}
278277----
279278
280- (((future)))(((execution order)))This is a function _declaration_. The
281- statement defines the variable `square` and points it at the given
282- function. So far so good. There is one subtlety with this form of
283- function definition, however.
279+ (((future)))(((execution order)))Bu funksiya _bəyanıdır_(declaration).
280+ Bu bəyanat `kvadrat` dəyişənini elan edir və verilmiş funksiyaya işarə
281+ edir. Bəyanatın bu cür formasında bir incə(sublety) məqam var.
284282
285283[source,javascript]
286284----
287- console.log("The future says :", future ());
285+ console.log("Gələcək deyir :", gelecek ());
288286
289- function future () {
290- return "We STILL have no flying cars .";
287+ function gelecek () {
288+ return "Hələ də uçan avtomobillərimiz yoxdur .";
291289}
292290----
293291
294- This code works, even though the function is defined _below_ the code
295- that uses it. This is because function declarations are not part of
296- the regular top-to-bottom flow of control. They are conceptually moved
297- to the top of their scope and can be used by all the code in that
298- scope. This is sometimes useful because it gives us the freedom to
299- order code in a way that seems meaningful, without worrying about
300- having to define all functions above their first use.
301-
302- (((function,declaration)))What happens when you put such a function
303- definition inside a conditional (`if`) block or a loop? Well, don't do
304- that. Different JavaScript platforms in different browsers have
305- traditionally done different things in that situation, and the latest
306- ((standard )) actually forbids it. If you want your programs to behave
307- consistently, only use this form of function-defining statements in
308- the outermost block of a function or program .
292+ Baxmayaraq ki, funksiyanın elanı istifadəsindən _aşağıda_ yer alıb,
293+ bu kod işləyəcək. Bu ona görədir ki, funksiya bəyanları adi yuxarıdan-
294+ aşağıya nəzarət axınının ( flow of control) bir hissəsi deyil. Onlar
295+ konsept olaraq öz təsir çərçivəsininin( scope) yuxarısına köçürülür və həmin
296+ çərçivə daxilində bütün kodda istifadə oluna bilər. Bu bəzən yararlıdır,
297+ çünki bu bizə kodu, funksiya bəyanlarını kodun yuxarısında və ya aşağısında
298+ yerləşdirməyimizdən asılı olmayaraq, bizə məntiqli görünən - istədiyimiz
299+ strukturla yazmaq imkanı verir.
300+
301+ (((function,declaration)))Bəs funksiya elanlarını şərt (`if`) və ya dövr
302+ blokuna yerləşdirdikdə nə baş verir? Bunu etməyin. Belə vəziyyətdə fərqli
303+ JavaScript platformaları fərqli brauzerlərdə müxtəlif nəticələr vermişlər
304+ və ən son ((standart )) bunu ümumiyyətlə qadağan edir. Əgər proqramınızın
305+ davamlı olmağını istəyirsinizsə, bu cür funksiya elanlarını ancaq
306+ funksiyanın və ya proqramın səvviyəcə ən üst blokunda edin .
309307
310308[source,javascript]
311309----
312- function example () {
313- function a() {} // Okay
314- if (something ) {
315- function b() {} // Danger !
310+ function numune () {
311+ function a() {} // OK
312+ if (nə isə ) {
313+ function b() {} // Təhlükə !
316314 }
317315}
318316----
@@ -321,129 +319,123 @@ function example() {
321319== The call stack ==
322320
323321indexsee:[stack,call stack]
324- (((call stack)))(((function,application)))It will be helpful to take a
325- closer look at the way control flows through functions. Here is a
326- simple program that makes a few function calls :
322+ (((call stack)))(((function,application)))Kodda ardıcıllığın(axın) necə təmin
323+ olunduğuna yaxından baxaq. Aşağıda bir neçə funksiya çağırışı edən kiçik
324+ proqrama baxaq :
327325
328326[source,javascript]
329327----
330- function greet(who ) {
331- console.log("Hello " + who );
328+ function salamla(kim ) {
329+ console.log("Salam " + kim );
332330}
333- greet("Harry ");
334- console.log("Bye ");
331+ salamla("Aysel ");
332+ console.log("Hələlik ");
335333----
336334
337- (((control flow)))(((execution order)))(((console.log)))A run through
338- this program goes roughly like this: the call to `greet` causes
339- control to jump to the start of that function (line 2). It calls
340- `console.log` (a built-in browser function), which takes control, does
341- its job, and then returns control to line 2. Then it reaches the end
342- of the `greet` function, so it returns to the place that called it, at
343- line 4. The line after that calls `console.log` again .
335+ (((control flow)))(((execution order)))(((console.log)))Burada nəzarət axını
336+ kobud olaraq belə baş verir: `salamla` funksiyasının çağırışı nəzarət axının
337+ funksiyanın başlanğıcına getməsinə səbəb olur (sətir 2). O da öz növbəsində
338+ nəzarət axınını ələ keçirən `console.log` -u (brauzer funksiyası) çağırır,
339+ öz işini görür və yenidən sətir 2-ə qayıdır. Bundan sonra `salamla` funksiyasının
340+ sonuna çatır, onun çağırıldığı sətirə, yəni 4-cü sətirə geri qayıdır. Bundan
341+ sonrakı sətir `console.log`-u yenidən çağırır .
344342
345- We could show the flow of control schematically like this :
343+ Sxematik olaraq bunu aşağıdakı kimi göstərmək olar :
346344
347345----
348- top
349- greet
346+ üst
347+ salamla
350348 console.log
351- greet
352- top
349+ salamla
350+ üst
353351 console.log
354- top
352+ üst
355353----
356354
357- (((return keyword)))(((memory)))Because a function has to jump back to
358- the place of the call when it returns, the computer must remember the
359- context from which the function was called. In one case, `console.log`
360- has to jump back to the `greet` function. In the other case, it jumps
361- back to the end of the program.
362-
363- The place where the computer stores this context is the _((call
364- stack))_. Every time a function is called, the current context is put
365- on top of this “stack”. When the function returns, it removes the top
366- context from the stack and uses it to continue execution.
367-
368- (((infinite loop)))(((stack overflow)))(((recursion)))Storing this
369- stack requires space in the computer's memory. When the stack grows
370- too big, the computer will fail with a message like “out of stack
371- space” or “too much recursion”. The following code illustrates this by
372- asking the computer a really hard question, which causes an infinite
373- back-and-forth between two functions. Rather, it _would_ be infinite,
374- if the computer had an infinite stack. As it is, we will run out of
375- space, or “blow the stack”.
355+ (((return keyword)))(((memory)))Funksiya çağırılıb yekunlaşdıqdan sonra
356+ nəzarət axını çağırıldığı sətirə geri qayıtdığına görə kompüter həmin
357+ konteksti yadda saxlamalıdır. Bir halda `console.log` `salamla` funksiyasına
358+ tullanır, digər halda isə proqramın sonuna aparır.
359+
360+ Kompüterin bu konteksti saxladığı yer isə _((sorğu steki))_ (call stack) adlanır.
361+ Hər dəfə funksiya çağırılanda, cari konktest bu “stekin” yuxarısına yerləşdirilir.
362+ Funksiyanın icrası başa çatdıqda ən üstdəki konktest stekdən kənarlaşdırılır
363+ və proqramın sonrakı icrası üçün istifadə olunur.
364+
365+ (((infinite loop)))(((stack overflow)))(((recursion)))Bu steki saxlamaq
366+ kompüterin yaddaşında yer tələb edir. Stek çox böyüdükcə kompüter “stek
367+ yaddaşı dolub” və ya “həddindən çox rekursiya” ismarıcı ilə səhv verə
368+ bilər (fail). Aşağıdakı kod bunu kompüterə çox çətin sual verməklə,
369+ iki funksiya arasında sonsuz önə-arxaya getməklə nümayiş etdirir.
370+ Kompüterin steki sonsuz olsaydı, sonsuz olaraq bu proses davam edəcəkdi.
371+ Olmadığına görə yaddaş “dolub daşacaq”.
376372
377373// test: no
378374
379375[source,javascript]
380376----
381- function chicken () {
382- return egg ();
377+ function toyuq () {
378+ return yumurta ();
383379}
384- function egg () {
385- return chicken ();
380+ function yumurta () {
381+ return toyuq ();
386382}
387- console.log(chicken () + " came first .");
383+ console.log(toyuq () + " birinci yaranıb .");
388384// → ??
389385----
390386
391- == Optional Arguments ==
387+ == Könüllü(optional) Arqumentlər ==
392388
393- (((argument)))(((function,application)))The following code is allowed
394- and executes without any problem:
389+ (((argument)))(((function,application)))Aşağıdakı kod səhvsiz icra olunur:
395390
396391[source,javascript]
397392----
398- alert("Hello ", "Good Evening ", "How do you do ?");
393+ alert("Salam ", "Axşamın xeyir ", "Necəsən ?");
399394----
400395
401- (((alert function)))The function `alert` officially accepts only one
402- argument. Yet when you call it like this, it doesn't complain. It
403- simply ignores the other arguments and shows you “Hello” .
396+ (((alert function)))`alert` funksiyası rəsmi olaraq yalnız bir arqument
397+ qəbul edir. Buna baxmayaraq belə çağırdıqda heç bir səhv baş vermir.
398+ Sadəcə digər arqumentlərə məhəl qoyulmur (ignores) və “Salam” çıxarır .
404399
405- (((undefined)))(((parameter)))JavaScript is extremely broad-minded
406- about the number of arguments you pass to a function. If you pass too
407- many, the extra ones are ignored. If you pass too few, the missing
408- parameters simply get assigned the value `undefined`.
400+ (((undefined)))(((parameter)))JavaScript funksiyaya ötürülən arqumentlərin
401+ sayına görə çox tolerantdır (broad-minded). Əgər lazımdan çox ötürmüsünüzsə,
402+ əlavələ sadəcə iqnor olunacaq, əksinə, lazımından az ötürülürsə, buraxılmış
403+ arqumentlərə sadəcə olaraq `undefined` mənimsədilir .
409404
410- The downside of this is that it is possible—likely, even—that you'll
411- accidentally pass the wrong number of arguments to functions and no
412- one will tell you about it.
405+ Bunun mənfi tərəfi odur ki, funksiyaya təsadüfən arqumentlərin sayını səhv
406+ ötürsəniz, heç kim sizə bu haqda deməyəcək.
413407
414408[[power]]
415- (((power example)))(((optional argument)))The
416- upside is that this behavior can be used to have a function take
417- “optional” arguments. For example, the following version of `power`
418- can be called either with two arguments or with a single argument, in
419- which case the exponent is assumed to be two, and the function behaves
420- like `square`.
409+ (((power example)))(((optional argument)))Üstün tərəfi isə odur ki,
410+ “könüllü” (“optional”) arqumentlər yarada bilərik. Məsələn, `quvvet` -in
411+ aşağıdakı versiyası iki arqumentlə də, bir arqumentlə də icra oluna bilər.
412+ Bir arqumentli halda eksponent iki götürülür və `kvadrat` funksiyası kimi
413+ davranır.
421414
422415// test: wrap
423416
424417[source,javascript]
425418----
426- function power(base, exponent ) {
427- if (exponent == undefined)
428- exponent = 2;
429- var result = 1;
430- for (var count = 0; count < exponent; count ++)
431- result *= base ;
432- return result ;
419+ function quvvet(esas, eksponent ) {
420+ if (eksponent == undefined)
421+ eksponent = 2;
422+ var netice = 1;
423+ for (var say = 0; say < eksponent; say ++)
424+ netice *= esas ;
425+ return netice ;
433426}
434427
435- console.log(power (4));
428+ console.log(quvvet (4));
436429// → 16
437- console.log(power (4, 3));
430+ console.log(quvvet (4, 3));
438431// → 64
439432----
440433
441- (((console.log)))In the link:04_data.html#arguments_object[next
442- chapter], we will see a way in which a function body can get at the
443- exact list of arguments that were passed. This is helpful because it
444- makes it possible for a function to accept any number of arguments.
445- For example, `console.log` makes use of this—it outputs all of the
446- values it is given.
434+ (((console.log)))In the link:04_data.html#arguments_object[Növbəti
435+ fəsildə] funksiyanın gövdəsinin ötürülən arqumentlərin sayını necə
436+ dəqiq müəyyənləşdirdiyini görəcəyik. İstədiyimiz sayda arqument
437+ ötürə bilmək cəhətdən bu çox yararlıdır. `console.log` bundan
438+ istifadə edərək ötürdüyümüz bütün arqumentləri çap edir.
447439
448440[source,javascript]
449441----
0 commit comments