💚MonoBehaviour💚 is the base class from which every Unity script derives. Any Unity3D script that you create will extend from the MonoBehaviour class. The MonoBehaviour class will execute events in a pre-determined order. 🍱Method: A method is a function that performs a specific task. So these methods are performing a specific function. For example whatever code is written inside the Start() will execute on the
Functions as objects
In JavaScript functions are a type of object known as function object. You can work with function objects as though they were objects. Functions may be assigned to objects, passed in as arguments to other functions, returned from other functions. Additionally a function can be passed into an array. And this gets me to earlier in my articles when I’ve stated “almost everything in JavaScript
Getters & Setters in JavaScript – part 2
carrying on from part 1 .. Getters in JavaScript Getters are functions that retrieve a value from static properties from an external source. You can only access properties and cannot access methods as they are functions of an object or class and are not static.There are three ways you can use getters and setters:1. Default method syntax2. get keyword3. Object.defineProperty() method We will now discuss
Setters and Getters in JavaScript – part 1
Accessors: Getters and Setters This is part 1 of a brief introduction to getters and setters in JavaScript. Getters and Setters are ES5 features. Objects have two types of properties: Static data property Accessor property So far we have come across static data properties in the objects that we have been making. For example: let blackLivesMatter = { status: true, usecase: ‘daily’ } In this
The break and continue statements in JavaScript
Break and continue statements The break statement is used to exit a loop completely once a condition has been met, or after x number of iterations. As such it is commonly used within an if conditional block. Take as an example the following code: for (let i = 0; i <= 5; i++){ console.log(i); } This will print out the value of variable i from
Deep and shallow copying in JavaScript – part 2
Copying objects with Shallow copy Now that we went over shallow and deep copies in part 1, let’s go over shallow copying in JavaScript. There are 3 ways to create shallow copies in JavaScript: Iteration using for key in an object Spread operator Object.assign() 1. Iteration using for key in an object In order to copy the items of an object into another object we
Pass by reference vs Pass by Value
Pass by value Non-primitive data types are passed by reference compared to primitive data types that are passed by value. As such non-primitive data types are also called reference types. To understand why they’re called reference types, we need to briefly look at how variables are stored in memory. A fixed amount of memory is allocated to a variable after it is declared. For primitive
The Learn How to Code Planner
ps: If you just want to download, go here: https://bit.ly/3biXP4j Learning how to code can be overwhelming! Often learners confuse a curriculum with a plan to learn coding. A curriculum is a list of topics on a particular subject for example JavaScript or python. Whereas, a planning involves the steps including the time and energy commitments to finish the curriculum. Common problematic pattern As I
Enumerated types (Enum) in C++
Enum is a user defined data type in C++ whose value is equal to some user defined values. For example: Enum is useful for switch cases, when we expect a variable to have only one of the possible set of values. For example, we can change the code to:
Adding/pushing data to a vector in C++
Adding data to a vector in C++ rephrased means “Push data/element into an array” in JavaScript. JavaScript uses the “push” method whereas C++ uses “push_back” In JavaScript you push an element into an array like so: The same way in C++ :