javascript tutorial 6

PPTX 12 pages 242.2 KB Free download

Page preview (5 pages)

Scroll down 👇
1 / 12
javascript tutorial 6 2. prototypes and inheritance javascript uses prototypal inheritance instead of classical inheritance. understanding prototypes is key to working with objects and inheritance in javascript. key concepts: prototype chain : every object in javascript has a prototype, and it can inherit properties and methods from its prototype. __proto__ vs. prototype : __proto__ refers to the prototype of an object, while prototype is used when defining constructor functions. class syntax : es6 introduced the class keyword, which is syntactic sugar over prototypal inheritance. example: function person(name) { this.name = name; } person.prototype.greet = function() { console.log(`hello, my name is ${this.name}`); }; const person1 = new person('alice'); person1.greet(); // output: hello, my name is alice 3. modules (es6 modules) javascript supports modular programming using es6 modules . modules allow you to split your code into smaller, reusable files. key concepts: import and export : used to import and export functions, …
2 / 12
ot allowed'); } return a / b; } try { console.log(divide(10, 0)); } catch (error) { console.error(error.message); // output: division by zero is not allowed } 5. generators generators are functions that can be paused and resumed, allowing you to produce a sequence of values over time. they are defined using the function* syntax and use the yield keyword. key concepts: yield : pauses the function execution and returns a value. next() : resumes the generator function and returns an object with value and done. example: function* generatesequence() { yield 1; yield 2; yield 3; } const generator = generatesequence(); console.log(generator.next().value); // output: 1 console.log(generator.next().value); // output: 2 console.log(generator.next().value); // output: 3 6. proxy and reflect the proxy object allows you to define custom behavior for fundamental operations (e.g., property lookup, assignment). the reflect object provides methods for interceptable javascript operations. key concepts: proxy : allows you to intercept and …
3 / 12
set); // output: set { 1, 2, 3, 4 } 8. weakmap and weakset these are similar to map and set, but they hold weak references to their keys, meaning they don't prevent garbage collection. key concepts: weakmap : keys must be objects, and they are weakly held. weakset : only stores objects, and they are weakly held. example: let obj = { id: 1 }; const weakmap = new weakmap(); weakmap.set(obj, 'data'); console.log(weakmap.get(obj)); // output: data obj = null; // object is now eligible for garbage collection 9. typed arrays and arraybuffer javascript provides typed arrays for working with binary data, such as images, audio, or network protocols. these are more efficient than regular arrays for handling large amounts of binary data. key concepts: arraybuffer : represents a fixed-length raw binary data buffer. typedarray : views into the arraybuffer (e.g., uint8array, int32array). example: const buffer = new arraybuffer(16); // …
4 / 12
javascript tutorial 6 - Page 4
5 / 12
javascript tutorial 6 - Page 5

Want to read more?

Download all 12 pages for free via Telegram.

Download full file

About "javascript tutorial 6"

javascript tutorial 6 2. prototypes and inheritance javascript uses prototypal inheritance instead of classical inheritance. understanding prototypes is key to working with objects and inheritance in javascript. key concepts: prototype chain : every object in javascript has a prototype, and it can inherit properties and methods from its prototype. __proto__ vs. prototype : __proto__ refers to the prototype of an object, while prototype is used when defining constructor functions. class syntax : es6 introduced the class keyword, which is syntactic sugar over prototypal inheritance. example: function person(name) { this.name = name; } person.prototype.greet = function() { console.log(`hello, my name is ${this.name}`); }; const person1 = new person('alice'); person1.greet(); // output: hello,...

This file contains 12 pages in PPTX format (242.2 KB). To download "javascript tutorial 6", click the Telegram button on the left.

Tags: javascript tutorial 6 PPTX 12 pages Free download Telegram