User Tools

Site Tools


JXA_JavaScript_for_Applications

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
JXA_JavaScript_for_Applications [2016/01/05 18:59]
ComplexPoint [Attaching reusable names to computations and their results:]
JXA_JavaScript_for_Applications [2016/01/06 21:17]
peternlewis deleted in favor of JavaScript for Automation
Line 182: Line 182:
 Where AS uses the pattern: ​   **set** *name* **to** *resultingValue* (and reserves **=** for testing equality), Where AS uses the pattern: ​   **set** *name* **to** *resultingValue* (and reserves **=** for testing equality),
  
-JS uses one or more [[https://​developer.mozilla.org/​en/​docs/​Web/​JavaScript/​Reference/​Statements/​var|variable declaration statements]]+JS uses one or more [[https://​developer.mozilla.org/​en/​docs/​Web/​JavaScript/​Reference/​Statements/​var|variable declaration statements]] ​(and [[https://​developer.mozilla.org/​en-US/​docs/​Web/​JavaScript/​Equality_comparisons_and_sameness|tests equality]] with **===**)
  
 In JS we can either: In JS we can either:
Line 203: Line 203:
  
 JavaScript gives us a lot of freedom, [[http://​shop.oreilly.com/​product/​9780596517748.do|sometimes more than is helpful]]. Misspelled variable names, and accidental uses of the same globally visible name in different parts of a script are rich sources of puzzling bugs and wasted time. To use a less liberal but more helpful set of JavaScript rules, we can add the line **'use strict';​** JavaScript gives us a lot of freedom, [[http://​shop.oreilly.com/​product/​9780596517748.do|sometimes more than is helpful]]. Misspelled variable names, and accidental uses of the same globally visible name in different parts of a script are rich sources of puzzling bugs and wasted time. To use a less liberal but more helpful set of JavaScript rules, we can add the line **'use strict';​**
-at the start of a function. When we do this, JavaScript checks that all of our variables are declared (and therefore '​local'​ – visible only to their containing functions, and also temporary – vanishing when a function is finished). If an undeclared variable is detected when the **'use strict';​** statement has been added, we are given a helpful warning:+at the start of a function. When we do this, JavaScript checks that all of our variables are declared (and therefore '​local'​ – visible only to their containing functions, and also temporary – vanishing when the evaluation of a function is completed). If an undeclared variable ​name is detected when the **'use strict';​** statement has been added, we are given a helpful warning:
  
 {{::​use-strictpng.png|}} {{::​use-strictpng.png|}}
 +====Structuring collections – indexing by number, and by name===
 +
 +to follow ...
 +
 +====Structuring computations – branching, repetition, and nested composition====
 +
 +to follow ...
 +
 +====JSON for persistence – saving things between macro runs, and reading them straight back in====
 +
 +to follow ...
 +
 +=====The Automation interface=====
 +
 +===Using the Standard Additions library====
 +
 +to follow ...
 +
 +===Interacting with scriptable applications===
 +
 +to follow ...
 +
 +=====Using the Safari JSContexts Debugger (El Capitan onwards)=====
 +
 +to follow ...
 +
 +=====The ObjC interface=====
 +
 +to follow ...
 +
 +===Basic file functions===
 +
 +to follow ...
 +
 +===Clipboard functions===
 +
 +to follow ...
 +
 +===Reading the documentation for simple ObjC functions===
 +
 +to follow ...