Welcome to my personal blog about coding, my name is Yves Roulin.

Hello World!

JS - Pass by Value or by Reference

Primitives types such as: Strings, numbers, boolean, undefined, null and symbol (ES6) are passed by value (You are passing a COPY) All objects (including functions, because yes, functions are objects) are passed by Reference (Something that points to the real object (same memory space)) Passing by value: "use strict" let a = 1; function foo(a) { a = 2; } foo(); console.log(a); Output: 1; Passing by reference: "use strict" let c = { greeting: 'hi' }; let d; d = c; c.

Posted

#JS

Array.prototype.Helpers

Array Helper Methods are very helpful when you need to manipulate your data stored in arrays. They make life much easier, so we should know them. forEach Helper The forEach() function is used to iterates through all the entries of the array. ES5 Example: var colors = ['red','blue','green']; <script> colors.forEach(function(color){ console.log(color); }); </script> Output: red blue green ES6 Example: <script> colors.forEach(color => { console.log(color); }); </script> Every Helper The every() method tests whether all elements in the array pass the test implemented by the provided function, example: Check if all the values in the computers array are 16 or over:

Posted

#JS

Pico 8 Shooter Game

¡Juega mi shooter retro!

Posted

#Pico-8

JS - Data Types

JavaScript has 8 built-in data types (with the latest ECMAScript standard): We have the Primitives ones: Null Boolean Undefined Number BigInt String Symbol and the Objects. And you can check the type of each data type with the typeof operator: let helloMessage = "Hello World"; typeof(helloMessage); //Output: "string" let myAge = 32; typeof(myAge); //Output: "number" const myPerson = { name: 'Yves', age: 32, } typeof(myPerson); //Output: "object" We have also have undefined and undeclared which is basically when you define a variable without a value (the default value is undefined).

Posted

#JS

JS - What Is Use Strict and What Does It Do

The keyword ‘use strict’ means that the JavaScript engine will be pickier about certain things we do when we write code. It turns on the strict mode operating context wherever you place it (inside of a function will activate strict mode on the function level scope) including: Using a variable before it’s defined now causes an error. It stops you from using words that are reserved for future versions of JS.

Posted

#JS