JavaScript javascript doing new to different name

I understand the word self has no special meaning in javascript. Below code, while if one writes as var Life = function( ....), it's clear but author decide to do var _ = self.Life = function(...). While I understand the var _ part(so that internally, it can refer to samething by shorter name), I don't get self.Life (instead of Life).. Can someone please explain this?

(function() {
    var _ = self.Life = function(seed) {
        this.seed = seed;
        this.height = seed.length;
        this.width = seed[0].length;
        this.prevBoard = [];
        this.board = cloneArray(seed);
    };
    _.prototype = {
        next: function() {
            //
        },
        toString: function() {
            return this.board.map(function(row) {
                return row.join(' ');
            }).join('\n');
        }
    };

    function cloneArray(array) {
        return array.slice().map(function(row) {
            return row.slice();
        });
    }
})();
undefined
var game = new Life([
    [0, 0, 0, 0],
    [0, 0, 1, 0],
    [0, 1, 0, 1]
]);
undefined
console.log(game + ' ');
Answer:1

I understand the word self has no special meaning in javascript.

No, but it is a predefined global on browsers, referring to the current window (like window does*). So

var _ = self.Life = function...

...is making Life a global without falling prey to The Horror of Implicit Globals**.

Live brief example:

(function() {
  var _ = self.Life = function() {
    console.log("Hi there");
  };
  new _();
})();
new Life();
Answer:2

I have this JSON file on my server: {"1504929411112":{"name":"user1","score":"10"},"1504929416574":{"name":"2nduser","score":"14"},"1504929754610":{"name":"usr3","score":"99"},"1504929762722":{"name":...

I have this JSON file on my server: {"1504929411112":{"name":"user1","score":"10"},"1504929416574":{"name":"2nduser","score":"14"},"1504929754610":{"name":"usr3","score":"99"},"1504929762722":{"name":...

  1. node sort json array
  2. node sort json
  3. node json sort keys
  4. node js sort json array
  5. node js sort json by value
  6. node js sort json object
  7. node js sort json
  8. node js sort json by date
  9. node js sort json alphabetically
  10. node.js sort json array

Angular cancels a $http call when the timeout promise gets resolved or when the timeout if passed as integer exceeds the specified time. I created an implementation in my projects that cancels ...

Angular cancels a $http call when the timeout promise gets resolved or when the timeout if passed as integer exceeds the specified time. I created an implementation in my projects that cancels ...

  1. what happens when session timeout in asp.net
  2. what happens when session timeout in java
  3. what happens after session timeout
  4. what happens in a timeout

I have a function: renderConversations(){ let conversationContent = this.state.conversationArray.map((convObj, i) => { return <View key={i} style={[globalStyle.conversationContainer,...

I have a function: renderConversations(){ let conversationContent = this.state.conversationArray.map((convObj, i) => { return <View key={i} style={[globalStyle.conversationContainer,...

  1. iterate over array javascript
  2. iterate over array python
  3. iterate over array java
  4. iterate over array bash
  5. iterate over array golang
  6. iterate over array of objects javascript
  7. iterate over array ruby
  8. iterate over array c++
  9. iterate over array java 8
  10. iterate over array php
  11. iterate over array matlab
  12. iterate over array swift
  13. iterate over array typescript
  14. iterate over array react
  15. iterate over array perl
  16. iterate over array scala
  17. iterate over array jquery
  18. iterate over array rust
  19. iterate over array es6
  20. iterate over array powershell

I know of this question: Convert relative path to absolute using JavaScript But it is about JavaScript that runs in a browser. My JS runs on Windows (WSH). That means I don't have the following ...

I know of this question: Convert relative path to absolute using JavaScript But it is about JavaScript that runs in a browser. My JS runs on Windows (WSH). That means I don't have the following ...

  1. convert relative path to absolute path
  2. convert relative path to absolute path python
  3. convert relative path to absolute path bash
  4. convert relative path to absolute path java
  5. convert relative path to absolute path powershell
  6. convert relative path to absolute path c#
  7. convert relative path to absolute path nodejs
  8. convert relative path to absolute path javascript
  9. convert relative path to uri
  10. linux convert relative path to absolute
  11. php convert relative path to absolute
  12. cmake convert relative path to absolute
  13. node convert relative path to absolute
  14. shell convert relative path to absolute
  15. matlab convert relative path to absolute
  16. svg convert relative path to absolute
  17. perl convert relative path to absolute
  18. ansible convert relative path to absolute
  19. ruby convert relative path to absolute
  20. makefile convert relative path to absolute