bind() function in JavaScript

Posted by & filed under JavaScript.

JavaScript

bind() method creates a new function, when called has its this keyword set to the provided value Let’s have a look at a sample code, on how to use the bind() function: const person = { age: 20, getAge: function() { return this.age; } } const unBoundedGetAge = person.getAge; console.log(unBoundedGetAge()) If we run the code,… Read more »

call() function in JavaScript

Posted by & filed under JavaScript.

JavaScript

call() or Function.prototype.call() method calls a function with a given this value and arguments. Let’s have a look at an example how to use call() method: function Product(name, price) { this.name = name; this.price = price; } function Food(name, price) { Product.call(this, name, price); this.category = ‘food’; } console.log(new Food(‘cheese’, 5).name); Output: cheese apply() or… Read more »

Cypress.io 4.0 supports Firefox and Edge browsers

Posted by & filed under Frameworks, JavaScript, Test Automation.

Cypress

Cypress.io announced that with v4.0, Mozilla Firefox and Microsoft Edge (Chromium based) browsers are supported. Have a look how to get started with Cypress in less than 30 minutes. This update is quite huge for the software testing community, since the other competitor of Cypress.io, TestCafe was supporting Firefox and Edge browsers for a while… Read more »

‘use strict’ in JavaScript

Posted by & filed under Frameworks, JavaScript.

JavaScript

When to add ‘use strict’ in JavaScript and what implications implies. If you don’t use ‘use strict’, the context of this will be the global window object. function getName() { console.log(this) } getName() When using strict mode, the context of this inside a function on the global context will be undefined: ‘use strict’ function getName()… Read more »