From da78a9e329e272dedb2400b79a3bdeebff387d47 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:42:17 -0500 Subject: initial commit --- files/my/web/javascript/index.html | 104 +++++++ files/my/web/javascript/reference/index.html | 312 +++++++++++++++++++++ .../reference/statements/function_star_/index.html | 252 +++++++++++++++++ .../web/javascript/reference/statements/index.html | 130 +++++++++ 4 files changed, 798 insertions(+) create mode 100644 files/my/web/javascript/index.html create mode 100644 files/my/web/javascript/reference/index.html create mode 100644 files/my/web/javascript/reference/statements/function_star_/index.html create mode 100644 files/my/web/javascript/reference/statements/index.html (limited to 'files/my/web/javascript') diff --git a/files/my/web/javascript/index.html b/files/my/web/javascript/index.html new file mode 100644 index 0000000000..d26ea34fb6 --- /dev/null +++ b/files/my/web/javascript/index.html @@ -0,0 +1,104 @@ +--- +title: JavaScript +slug: Web/JavaScript +tags: + - JavaScript + - Landing + - NeedsTranslation + - TopicStub +translation_of: Web/JavaScript +--- +
{{JsSidebar}}
+ +

JavaScript® (အတိုကောက် JS) ဆိုတာ   first-class functions  နှင့်တည်ဆောက်ထား တဲ့a  lightweight, interpreted, object-oriented language တစ်ခုဖြစ်ပါတယ်။အများက သိတာကတော့ web pages တွေအတွက် browser ကိုအခြေ ခံထားတဲ့ scripting language တစ်ခုအနေနဲ့သိကြတယ် ဒါပေမဲ့ browser ကိုအခြေခံ မထားတဲ့ နေရာ တွေဖြစ်တဲ့  node.js ဒါမှမဟုတ်  Apache CouchDB တွေမှာလဲအသုံးပြု ပါတယ်. Javascript ဟာ  prototype-based, multi-paradigm scripting language ဖြစ်ပါတယ်၊ ဆိုလိုတာက dynamic ဖြစ်သလို object-oriented, imperative, and functional programming ရေးသားနည်းပုံစံနဲ့လည်း ထောက်ပံပေးပါတယ်။ အသေးစိတ်ကိုတော့ JavaScript အကြောင်း ပိုမို ဖတ်ရှုကြည့်ပါ။

+ +

JavaScript စံသတ်မှတ်ချက်ကို ECMAScript လို့ခေါ်ပါတယ်။ ၂၀၁၂ မှာ modern browsers တွေအကုန်လုံးက ECMAScript 5.1 ကို အပြည့်အဝ support ပေးနေပါပြီ။ Browsers အဟောင်းတွေက အနည်းဆုံး ECMAScript 3 ကို support ပေးပါတယ်။ ဇွန်လ ၁၇ ရက် ၂၀၁၅ မှာ ခြောက်ကြိမ်မြောက် ECMAScript ကို ကြေငြာပြဌာန်းလိုက်ပါတယ်။ အဲ့ဒီ့ version ကို ECMAScript 2015 လို့တရားဝင်ခေါ်ပါတယ်၊ ဒါပေမယ့်လည်း ECMAScript 6 ဒါမှမဟုတ် ES6 ဆိုပြီးလည်းခေါ်ပါတယ်။

+ +

 ဒီဝက်စာမျက်နှာမှာတော့ JavaScript အကြောင်းကိုပဲ ပြောပြသွားမှာဖြစ်ပါတယ်။Web Pages နဲ့ ဆက်စပ်ပြီးသုံးတဲ့ ဒါမှမဟုတ် တစ်ခြားသော Host Environment နဲ့ စပ်ဆက်ပြီးသုံးတဲ့ အကြောင်းကို ပြောမှ မဟုတ်ပါဘူး။. Web pages နဲ့  စပ်ဆက်ပြီး အသုံးပြုတဲ့ {{Glossary("API","APIs")}}  ကို လေ့လာချင်တဲ့ဆိုရင်တော့ Web APIs နဲ့  DOM မှာ သွားရောက် လေ့လာလို့ရပါတယ်။

+ +

JavaScript ကို Java programming language နဲ့ မတူဘူးဆိုတာ သိထားဖို့လိုပါမယ်။ Java ဆိုတာ U.S. နဲ့ အခြားသောနိုင်ငံတွေမှာ Oracle က မူပိုင်တင်ထားပါတယ်။

+ +
+
+

နည်းပြသင်ခန်းစာများ

+ +

ကျွန်တော်တို့ရဲ့ နည်းပြသင်ခန်းစာများနဲ့ လေ့ကျင့်ခန်းများမှတစ်ဆင့် JavaScript နဲ့ဘယ်လို program လုပ်မလဲဆိုတာလေ့လာပါ။

+ +

နိဒါန်း

+ +
+
JavaScript လမ်းညွှန်
+
သင်က JavaScript ကိုအခုမှစတင်လေ့လာမယ့်သူဆိုရင် ဒီလမ်းညွှန်ကသင့်ကိုအထောက်အကူပြုပါလိမ့်မယ်။ 
+
+
JavaScript နည်းပညာချုံငုံသုံးသပ်ချက်
+
Web browser နဲ့ JavaScript landscape မိတ်ဆက်။
+
Object Oriented JavaScript မိတ်ဆက်
+
Introduction to the concepts of object oriented programming in JavaScript.
+
+ +

Intermediate

+ +
+
A re-introduction to JavaScript
+
An overview for those who think they know about JavaScript.
+
+ +
+
JavaScript data structures
+
Overview of available data structures in JavaScript.
+
Equality comparisons and sameness
+
JavaScript provides three different value-comparison operations: strict equality using ===, loose equality using ==, and the {{jsxref("Global_Objects/Object/is", "Object.is()")}} method.
+
+ +

Advanced

+ +
+
Inheritance and the prototype chain
+
Explanation of the widely misunderstood and under-estimated prototype-based inheritance.
+
Strict mode
+
A restricted variant of JavaScript.
+
JavaScript typed arrays
+
JavaScript typed arrays provide a mechanism for accessing raw binary data.
+
Memory Management
+
Memory life cycle and garbage collection in JavaScript.
+
+
+ +
+

အညွှန်း

+ +

Browse the complete JavaScript reference documentation. 

+ +
+
Standard objects
+
Get to know standard built-in objects Array, Boolean, Date, Error, Function, JSON, Math, Number, Object, RegExp, StringMap, Set, WeakMap, WeakSet, and others.
+
Expressions and operators
+
Learn more about the behavior of JavaScript's operators instanceof, typeof, new, this, the operator precedence, and more.
+
Statements and declarations
+
Learn how do-while, for-in, for-of, try-catch, let, var, const, if-else, switch, and more JavaScript statements and keywords work.
+
Functions
+
Learn how to work with JavaS functions to develop your applications.
+
+ +

Tools & resources

+ +

Helpful tools while writing and debugging your JavaScript code.

+ +
+
Firefox Developer Tools
+
Scratchpad, Web Console, JavaScript Profiler, Debugger, and more.
+
Firebug
+
Edit, debug, and monitor CSS, HTML, and JavaScript live in any web page.
+
JavaScript Shells
+
A JavaScript shell allows you to quickly test snippets of JavaScript code.
+
TogetherJS
+
+

Collaboration made easy.

+
+
Stack Overflow
+
Stack Overflow questions tagged with "JavaScript".
+
JavaScript versions and release notes
+
Browse JavaScript's feature history and implementation status.
+
+
+
diff --git a/files/my/web/javascript/reference/index.html b/files/my/web/javascript/reference/index.html new file mode 100644 index 0000000000..1345585f85 --- /dev/null +++ b/files/my/web/javascript/reference/index.html @@ -0,0 +1,312 @@ +--- +title: JavaScript reference +slug: Web/JavaScript/Reference +tags: + - Code + - ECMAScript + - ECMAScript6 + - ES6 + - JS + - JavaScript + - Landing page + - NeedsTranslation + - Reference + - TopicStub + - es + - 'l10n:priority' + - programming +translation_of: Web/JavaScript/Reference +--- +
{{JsSidebar}}
+ +

This part of the JavaScript section on MDN serves as a repository of facts about the JavaScript language. Read more about this reference.

+ +

Built-ins

+ +

JavaScript standard built-in objects, along with their methods and properties.

+ + + + + + + + + +

Statements

+ +

JavaScript statements and declarations

+ + + + + +

Expressions and operators

+ +

JavaScript expressions and operators

+ +
+ + + + + +
+ +

Functions

+ +

This chapter documents how to work with JavaScript functions to develop your applications.

+ + + +

Additional reference pages

+ + diff --git a/files/my/web/javascript/reference/statements/function_star_/index.html b/files/my/web/javascript/reference/statements/function_star_/index.html new file mode 100644 index 0000000000..414d5f4d63 --- /dev/null +++ b/files/my/web/javascript/reference/statements/function_star_/index.html @@ -0,0 +1,252 @@ +--- +title: function* +slug: Web/JavaScript/Reference/Statements/function* +translation_of: Web/JavaScript/Reference/Statements/function* +--- +
{{jsSidebar("Statements")}}
+ +

The function* declaration (function keyword followed by an asterisk) defines a generator function, which returns a {{jsxref("Global_Objects/Generator","Generator")}} object.

+ +
{{EmbedInteractiveExample("pages/js/statement-functionasterisk.html")}}
+ + + +

You can also define generator functions using the {{jsxref("GeneratorFunction")}} constructor, or the function expression syntax.

+ +

Syntax

+ +
function* name([param[, param[, ... param]]]) {
+   statements
+}
+
+ +
+
name
+
The function name.
+
param {{optional_inline}}
+
The name of a formal parameter for the function.
+
statements
+
The statements comprising the body of the function.
+
+ +

Description

+ +

Generators are functions that can be exited and later re-entered. Their context (variable bindings) will be saved across re-entrances.

+ +

Generators in JavaScript -- especially when combined with Promises -- are a very powerful tool for asynchronous programming as they mitigate -- if not entirely eliminate -- the problems with callbacks, such as Callback Hell and Inversion of Control. However, an even simpler solution to these problems can be achieved with {{jsxref("Statements/async_function", "async functions")}}.

+ +

Calling a generator function does not execute its body immediately; an iterator object for the function is returned instead. When the iterator's next() method is called, the generator function's body is executed until the first {{jsxref("Operators/yield", "yield")}} expression, which specifies the value to be returned from the iterator or, with {{jsxref("Operators/yield*", "yield*")}}, delegates to another generator function. The next() method returns an object with a value property containing the yielded value and a done property which indicates whether the generator has yielded its last value, as a boolean. Calling the next() method with an argument will resume the generator function execution, replacing the yield expression where an execution was paused with the argument from next().

+ +

A return statement in a generator, when executed, will make the generator finish (i.e. the done property of the object returned by it will be set to true). If a value is returned, it will be set as the value property of the object returned by the generator.
+ Much like a return statement, an error is thrown inside the generator will make the generator finished -- unless caught within the generator's body.
+ When a generator is finished, subsequent next() calls will not execute any of that generator's code, they will just return an object of this form: {value: undefined, done: true}.

+ +

Examples

+ +

Simple example

+ +
function* idMaker() {
+  var index = 0;
+  while (true)
+    yield index++;
+}
+
+var gen = idMaker();
+
+console.log(gen.next().value); // 0
+console.log(gen.next().value); // 1
+console.log(gen.next().value); // 2
+console.log(gen.next().value); // 3
+// ...
+ +

Example with yield*

+ +
function* anotherGenerator(i) {
+  yield i + 1;
+  yield i + 2;
+  yield i + 3;
+}
+
+function* generator(i) {
+  yield i;
+  yield* anotherGenerator(i);
+  yield i + 10;
+}
+
+var gen = generator(10);
+
+console.log(gen.next().value); // 10
+console.log(gen.next().value); // 11
+console.log(gen.next().value); // 12
+console.log(gen.next().value); // 13
+console.log(gen.next().value); // 20
+
+ +

Passing arguments into Generators

+ +
function* logGenerator() {
+  console.log(0);
+  console.log(1, yield);
+  console.log(2, yield);
+  console.log(3, yield);
+}
+
+var gen = logGenerator();
+
+// the first call of next executes from the start of the function
+// until the first yield statement
+gen.next();             // 0
+gen.next('pretzel');    // 1 pretzel
+gen.next('california'); // 2 california
+gen.next('mayonnaise'); // 3 mayonnaise
+
+ +

Return statement in a generator

+ +
function* yieldAndReturn() {
+  yield "Y";
+  return "R";
+  yield "unreachable";
+}
+
+var gen = yieldAndReturn()
+console.log(gen.next()); // { value: "Y", done: false }
+console.log(gen.next()); // { value: "R", done: true }
+console.log(gen.next()); // { value: undefined, done: true }
+
+ +

Generator as an object property

+ +
const someObj = {
+  *generator () {
+    yield 'a';
+    yield 'b';
+  }
+}
+
+const gen = someObj.generator()
+
+console.log(gen.next()); // { value: 'a', done: false }
+console.log(gen.next()); // { value: 'b', done: false }
+console.log(gen.next()); // { value: undefined, done: true }
+
+ +

Generator as an object method

+ +
class Foo {
+  *generator () {
+    yield 1;
+    yield 2;
+    yield 3;
+  }
+}
+
+const f = new Foo ();
+const gen = f.generator();
+
+console.log(gen.next()); // { value: 1, done: false }
+console.log(gen.next()); // { value: 2, done: false }
+console.log(gen.next()); // { value: 3, done: false }
+console.log(gen.next()); // { value: undefined, done: true }
+
+ +

Generator as a computed property

+ +
class Foo {
+  *[Symbol.iterator] () {
+    yield 1;
+    yield 2;
+  }
+}
+
+const SomeObj = {
+  *[Symbol.iterator] () {
+    yield 'a';
+    yield 'b';
+  }
+}
+
+console.log(Array.from(new Foo)); // [ 1, 2 ]
+console.log(Array.from(SomeObj)); // [ 'a', 'b' ]
+
+ +

Generators are not constructable

+ +
function* f() {}
+var obj = new f; // throws "TypeError: f is not a constructor
+
+ +

Generator defined in an expression

+ +
const foo = function* () {
+  yield 10;
+  yield 20;
+};
+
+const bar = foo();
+console.log(bar.next()); // {value: 10, done: false}
+ +

Generator example

+ +
function* powers(n){
+     //endless loop to generate
+     for(let current =n;; current *= n){
+         yield current;
+     }
+}
+
+for(let power of powers(2)){
+     //controlling generator
+     if(power > 32) break;
+     console.log(power)
+           //2
+          //4
+         //8
+        //16
+       //32
+}
+ +

Specifications

+ + + + + + + + + + + + +
Specification
{{SpecName('ESDraft', '#sec-generator-function-definitions', 'function*')}}
+ +

Browser compatibility

+ +
+ + +

{{Compat("javascript.statements.generator_function")}}

+
+ +

See also

+ + diff --git a/files/my/web/javascript/reference/statements/index.html b/files/my/web/javascript/reference/statements/index.html new file mode 100644 index 0000000000..b5f4f3d5e0 --- /dev/null +++ b/files/my/web/javascript/reference/statements/index.html @@ -0,0 +1,130 @@ +--- +title: Statements and declarations +slug: Web/JavaScript/Reference/Statements +tags: + - JavaScript + - Landing page + - NeedsTranslation + - Reference + - TopicStub + - statements +translation_of: Web/JavaScript/Reference/Statements +--- +
{{jsSidebar("Statements")}}
+ +

JavaScript applications consist of statements with an appropriate syntax. A single statement may span multiple lines. Multiple statements may occur on a single line if each statement is separated by a semicolon. This isn't a keyword, but a group of keywords.

+ +

Statements and declarations by category

+ +

For an alphabetical listing see the sidebar on the left.

+ +

Control flow

+ +
+
{{jsxref("Statements/block", "Block")}}
+
A block statement is used to group zero or more statements. The block is delimited by a pair of curly brackets.
+
{{jsxref("Statements/break", "break")}}
+
Terminates the current loop, switch, or label statement and transfers program control to the statement following the terminated statement.
+
{{jsxref("Statements/continue", "continue")}}
+
Terminates execution of the statements in the current iteration of the current or labeled loop, and continues execution of the loop with the next iteration.
+
{{jsxref("Statements/Empty", "Empty")}}
+
An empty statement is used to provide no statement, although the JavaScript syntax would expect one.
+
{{jsxref("Statements/if...else", "if...else")}}
+
Executes a statement if a specified condition is true. If the condition is false, another statement can be executed.
+
{{jsxref("Statements/switch", "switch")}}
+
Evaluates an expression, matching the expression's value to a case clause, and executes statements associated with that case.
+
{{jsxref("Statements/throw", "throw")}}
+
Throws a user-defined exception.
+
{{jsxref("Statements/try...catch", "try...catch")}}
+
Marks a block of statements to try, and specifies a response, should an exception be thrown.
+
+ +

Declarations

+ +
+
{{jsxref("Statements/var", "var")}}
+
Declares a variable, optionally initializing it to a value.
+
{{jsxref("Statements/let", "let")}}
+
Declares a block scope local variable, optionally initializing it to a value.
+
{{jsxref("Statements/const", "const")}}
+
Declares a read-only named constant.
+
+ +

Functions and classes

+ +
+
{{jsxref("Statements/function", "function")}}
+
Declares a function with the specified parameters.
+
{{jsxref("Statements/function*", "function*")}}
+
Generator Functions enable writing iterators more easily.
+
{{jsxref("Statements/async_function", "async function")}}
+
Declares an async function with the specified parameters.
+
{{jsxref("Statements/return", "return")}}
+
Specifies the value to be returned by a function.
+
{{jsxref("Statements/class", "class")}}
+
Declares a class.
+
+ +

Iterations

+ +
+
{{jsxref("Statements/do...while", "do...while")}}
+
Creates a loop that executes a specified statement until the test condition evaluates to false. The condition is evaluated after executing the statement, resulting in the specified statement executing at least once.
+
{{jsxref("Statements/for", "for")}}
+
Creates a loop that consists of three optional expressions, enclosed in parentheses and separated by semicolons, followed by a statement executed in the loop.
+
{{jsxref("Statements/for_each...in", "for each...in")}} 
+
Iterates a specified variable over all values of object's properties. For each distinct property, a specified statement is executed.
+
{{jsxref("Statements/for...in", "for...in")}}
+
Iterates over the enumerable properties of an object, in arbitrary order. For each distinct property, statements can be executed.
+
{{jsxref("Statements/for...of", "for...of")}}
+
Iterates over iterable objects (including {{jsxref("Global_Objects/Array","arrays","","true")}}, array-like objects, iterators and generators), invoking a custom iteration hook with statements to be executed for the value of each distinct property.
+
{{jsxref("Statements/for-await...of", "for await...of")}}
+
Iterates over async iterable objects, array-like objects, iterators and generators, invoking a custom iteration hook with statements to be executed for the value of each distinct property.
+
{{jsxref("Statements/while", "while")}}
+
Creates a loop that executes a specified statement as long as the test condition evaluates to true. The condition is evaluated before executing the statement.
+
+ +

Others

+ +
+
{{jsxref("Statements/debugger", "debugger")}}
+
Invokes any available debugging functionality. If no debugging functionality is available, this statement has no effect.
+
{{jsxref("Statements/export", "export")}}
+
Used to export functions to make them available for imports in external modules, and other scripts.
+
{{jsxref("Statements/import", "import")}}
+
Used to import functions exported from an external module, another script.
+
import.meta
+
An object exposing context-specific metadata to a JavaScript module.
+
{{jsxref("Statements/label", "label")}}
+
Provides a statement with an identifier that you can refer to using a break or continue statement.
+
+ +
+
{{jsxref("Statements/with", "with")}} 
+
Extends the scope chain for a statement.
+
+ +

Specifications

+ + + + + + + + + + +
Specification
{{SpecName('ESDraft', '#sec-ecmascript-language-statements-and-declarations', 'ECMAScript Language: Statements and Declarations')}}
+ +

Browser compatibility

+ + + +

{{Compat("javascript.statements")}}

+ +

See also

+ + -- cgit v1.2.3-54-g00ecf