Apr 18, 2022

TIL: Creating Globals

#programming #javascript

Today I learned you can create globals by passing unnecessary arguments to a function in javascript.

For example:

function myFunc(a) {

myFunc(123, (i=100));


Calling this function with that second argument expression will assign a global i to the value 100.

If you like this post, please share it on Twitter. You can also email me email me or subscribe to my RSS feed.