Category: Javascript

JavaScript — Loop Over an Array with forEach() Method

Chris Green August 27, 2018 No Comments Javascript , ,

You can use the forEach() method to loop over an array and execute a function on each element of the array. Example var pets = [‘dog’, ‘cat’, ‘monkey’]; pets.forEach(function(element) { console.log(element); }); // expected output: “dog” // expected output: “cat” // expected output: “monkey”   For more information: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach

Electron Error: Not allowed to load local resource

Chris Green August 25, 2018 No Comments Development, Javascript , , ,

I’ve recently begun playing with Electron (the library that lets you build cross-platform desktop apps with web technologies). And not long into trying to hook up my default HTML page I received this error: Not allowed to load local resource I was certain I’d typed the line to load the URL just like the tutorial […]

What is the JavaScript ternary operator?

Chris Green August 21, 2018 No Comments Javascript , ,

The ternary operator is a JavaScript Operator which will return one of two values depending on a conditional supplied. Basically, you supply any conditional which will evaluate out to true or false and it will return one of the two expressions. It is set  up as such: condition ? expression1 : expression2 If the condition […]

JavaScript — delete a property from an object

Chris Green August 20, 2018 No Comments Javascript , ,

You can remove a property from a JavaScript object with the delete operator. And it’s super easy: delete object.property Example var Car = { make: “Mazda”, model: “CX-5”, year: “2014” }; console.log(Car.year); // expected output: “2014” delete Car.year; console.log(Car.year); // expected output: undefined   For more information: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/delete

Page 1 of 1