Explained with simple and complex examples

Knowingly or Unknowingly, you have been dealing a lot with Type Coercion if you frequently code in JavaScript. Type Coercion is just a fancy name for implicit typecasting in JavaScript.

For more articles, visit https://www.knowledgescoops.com

Image for post
Image for post

Type Coercion Definition

As per MDN, Type Coercion refers to the automatic or implicit conversion of values from one type to another.

In JavaScript, if we execute the following statement

var val = '10' + 10;
console.log(val);

String ‘1010’ will get printed in the console. The number 10 is implicitly converted to string ‘10’ while executing the code. That’s what implicit type casting or type coercion.

No matter if we write the same statement…


JavaScript is weird !!! ( https://www.knowledgescoops.com )

Image for post
Image for post

Function Arguments

In a Javascript method, there exists a variable named “arguments” that contains all the parameters passed in the function call. “arguments” is an array-like object which contains parameters at indices and a property “length”.

function add() {
var sum = 0;
for (var i = 0; i < arguments.length; i++) {
sum += arguments[i];
}
return sum;
}
add(1, 2); // gives result 3 i.e. 1 + 2
add(1, 2, 3, 4); // gives result 10 i.e. 1 + 2 + 3 + 4

arguments is not a real array so you won’t be able to push or pop elements from it directly without converting it into the real array. …


Often you hay have seen sliding of UI panels when navigating across an app. Like clicking on the settings icon slides out the home screen and slides in the settings menu.

Image for post
Image for post

In this article, we will be creating a simple yet scalable sliding menu system that I am personally using in most of my Android games.

I will be using DoTween for making animations. So you need to install DoTween package in your Unity Project

Creating the Home and Settings Menu

To begin with, I have created a scene with two UI elements (Home and Settings menu) covering the complete screens as shown in the gif below. …

About

Kunal Tandon

Coder • Blogger • Problem Solver • 💁🏼‍♂️ Connect with me on LinkedIn @ http://bit.ly/kunal-tandon

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store