class Sell { constructor(date, quantity, price) { this._date = new Date(date.getTime()); // new instance this._quantity = quantity; this._price = price; … More
Category: javascript
[JS] – How to implement classes in JavaScript ?
Classes are the programmatic structures that define a business model. Example : We will define here the Client class in … More
[JS] – How do you make an object immutable?
For do this you can use the “freeze” method that has in the javascript Objects. This method not only allow the … More
[JS] What is the difference between “var” and “let” to declare a variable?
If you declare a variable via “var” syntax it can be accessed outside of the method as opposed to declaring a … More
[JS] – How to filter values in an array ?
Use Filter function : From Eloquent Javascript Book: “Note how the filter function, rather than deleting elements from the existing array, … More
[JS] – How to compare the values of two objects ?
Javascript function Write a function, deepEqual, that takes two values and returns true only if they are the same value … More
[JS] – How to implement functions ?
Passing values : var myFunc = function(x) { return x * x; }; console.log(myfunc(3)); // → 9 Without passing values … More
[JS] How to implement a switch ?
switch (conditional) { case “A”: console.log(“conditional == A”); break; case “B”: console.log(“conditional == B”); case “C”: console.log(“conditional == C”); … More
[JS] – How to implement while loops ?
while (condition) { {do something} } do (condition) { {do something} } while (conditional);
[JS] – What is the difference between == and === ?
Understanding by examples 0 == false Result : True. 0 is automatically converted to boolean. 0 === false Result : False. Don’t … More