JavaScript Classes, Inheritance

JavaScript Classes, Inheritance

Property getters and setters Accessor properties are represented by “getter” and “setter” methods. Getters/setters can be used as wrappers over “real” property values to gain more control over them. let user = { name: “Keshab”, surname: “Nayak”, get fullName() { return `${this.name} ${this.surname}`; }, set fullName(value) { [this.name, this.surname] = value.split(” “); } }; // set fullName is executed with the given value. user.fullName = […]

Read More Leave comment

JavaScript Advanced functions

JavaScript Advanced functions

“this” in methods To access the object, a method can use the this keyword. The value of this is the object “before dot”, the one used to call the method. let user = { name: “Keshab”, age: 30, sayHi() { alert(this.name); } }; user.sayHi(); // Keshab Constructor function Constructor functions technically are regular functions. There are two conventions though: They are named with capital letter […]

Read More Leave comment

JavaScript Garbage collection

JavaScript Garbage collection

Memory management in JavaScript is performed automatically and invisibly to us. We create primitives, objects, functions… All that takes memory. Object Reachability The main concept of memory management in JavaScript is object reachability. “object reachability” values are those that are accessible or usable somehow. “object reachability” if it’s reachable from a root by a reference or by a chain of references. There’s a background process in the JavaScript […]

Read More Leave comment

JavaScript Objects

JavaScript Objects

JavaScript is an object oriented language. In JavaScript we can define our own objects and assign methods, properties to it. In JavaScript objects are also associative arrays (or) hashes (key value pairs). Assign keys with obj[key] = value or obj.name = value. Remove keys with delete obj.name Iterate over keys with for(key in obj), Iteration order for string keys is always in definition order, for […]

Read More Leave comment

JavaScript Basic

JavaScript Basic

Interaction prompt(question[, default]) Ask a question, and return either what the visitor entered or null if he pressed “cancel”. confirm(question) Ask a question and suggest to choose between Ok and Cancel. The choice is returned as true/false. alert(message) Output a message. Operators Arithmetical Regular: * + – /, also % for the remainder and ** for power of a number. alert( ‘1’ + 2 ); […]

Read More Leave comment

JavaScript Functions

JavaScript Functions

Functions are the main “building blocks” of the program. They allow the code to be called many times without repetition. Function Declaration To create a function we can use a function declaration. function showMessage() { alert( ‘Hello everyone!’ ); } Function instance function showMessage() { alert( ‘Hello everyone!’ ); } showMessage(); showMessage(); Function Expression let Add = function(a, b) { let result = a + […]

Read More Leave comment

JavaScript Fundamentals

JavaScript Fundamentals

Hello, world! <!DOCTYPE HTML> <html> <body> <p>Before the script…</p> <script> alert( ‘Hello, world!’ ); </script> <p>…After the script.</p> </body> </html> Comments One-line comments start with the two forward slash characters //. // This comment occupies a line of its own alert(‘Hello’); alert(‘World’); // This comment follows the statement Multiline comments start with a forward slash and an asterisk /* and end with an asterisk and […]

Read More Leave comment

Introduction to JavaScript

Introduction to JavaScript

JavaScript is a very powerful client-side scripting language. JavaScript is used mainly for enhancing the interaction of a user with the webpage. In other words, you can make your webpage more lively and interactive, with the help of JavaScript. The language was initially called LiveScript and was later renamed JavaScript. The syntax of JavaScript is mostly influenced by the programming language C. JavaScript is a client […]

Read More Leave comment
Visitors
Page Hits: 51761
Unique Visitors :
12539
Made With By Keshab