Why new Array(4).join(“ha”) yields “hahahaha” and not “undefinedhaundefinedha ..”How do I check if an array includes an object in JavaScript?How to append something to an array?How do you access the matched groups in a JavaScript regular expression?Why is using “for…in” with array iteration a bad idea?Why does Google prepend while(1); to their JSON responses?Loop through an array in JavaScriptHow to check if an object is an array?Open a URL in a new tab (and not a new window) using JavaScriptHow do I remove a particular element from an array in JavaScript?For-each over an array in JavaScript?

Do interval ratios take overtones into account or solely the fundamental frequency?

Assembly of PCBs containing a mix of SMT and thru-hole parts?

Create the same subfolders in another folder

What happens to a net with the Returning Weapon artificer infusion after it hits?

Concerning a relationship in the team

Is the illusion created by Invoke Duplicity affected by difficult terrain?

Convert a string of digits from words to an integer

What is "degenerated ground point"?

Can I target any number of creatures, even if the ability would have no effect?

How deep is the liquid in a half-full hemisphere?

Is it ok if I haven't decided my research topic when I first meet with a potential phd advisor?

Selection Sort Algorithm (Python)

Population of post-Soviet states. Why decreasing?

What can Thomas Cook customers who have not yet departed do now it has stopped operating?

Pushing the e-pawn

Why aren't faces sharp in my f/1.8 portraits even though I'm carefully using center-point autofocus?

Why does Captain Marvel in the MCU not have her sash?

Dynamic DataSource for Droplist in Content Editor

What should I consider when deciding whether to delay an exam?

Why does it seem the best way to make a living is to invest in real estate?

How to say "respectively" in German when listing (enumerating) things

Garage door sticks on a bolt

Question about a degree 5 polynomial with no rational roots

How do my husband and I get over our fear of having another difficult baby?



Why new Array(4).join(“ha”) yields “hahahaha” and not “undefinedhaundefinedha ..”


How do I check if an array includes an object in JavaScript?How to append something to an array?How do you access the matched groups in a JavaScript regular expression?Why is using “for…in” with array iteration a bad idea?Why does Google prepend while(1); to their JSON responses?Loop through an array in JavaScriptHow to check if an object is an array?Open a URL in a new tab (and not a new window) using JavaScriptHow do I remove a particular element from an array in JavaScript?For-each over an array in JavaScript?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








5















Why new Array(4).join("ha") yields "hahaha" and not "undefinedhaundefinedha .." ?



var arr = new Array(4);
alert( arr[0] ); // produces `undefined`









share|improve this question
































    5















    Why new Array(4).join("ha") yields "hahaha" and not "undefinedhaundefinedha .." ?



    var arr = new Array(4);
    alert( arr[0] ); // produces `undefined`









    share|improve this question




























      5












      5








      5








      Why new Array(4).join("ha") yields "hahaha" and not "undefinedhaundefinedha .." ?



      var arr = new Array(4);
      alert( arr[0] ); // produces `undefined`









      share|improve this question
















      Why new Array(4).join("ha") yields "hahaha" and not "undefinedhaundefinedha .." ?



      var arr = new Array(4);
      alert( arr[0] ); // produces `undefined`






      javascript






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 28 at 19:41









      manonthemat

      3,41312 silver badges33 bronze badges




      3,41312 silver badges33 bronze badges










      asked Mar 28 at 19:30









      user10777718user10777718

      4051 silver badge10 bronze badges




      4051 silver badge10 bronze badges

























          1 Answer
          1






          active

          oldest

          votes


















          5
















          Elements of the array that are undefined or null are converted to the empty string. It's right there in the documentation.




          If an element is undefined or null, it is converted to the empty string.







          share|improve this answer



























            Your Answer






            StackExchange.ifUsing("editor", function ()
            StackExchange.using("externalEditor", function ()
            StackExchange.using("snippets", function ()
            StackExchange.snippets.init();
            );
            );
            , "code-snippets");

            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "1"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/4.0/"u003ecc by-sa 4.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );














            draft saved

            draft discarded
















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55405532%2fwhy-new-array4-joinha-yields-hahahaha-and-not-undefinedhaundefinedha%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            5
















            Elements of the array that are undefined or null are converted to the empty string. It's right there in the documentation.




            If an element is undefined or null, it is converted to the empty string.







            share|improve this answer





























              5
















              Elements of the array that are undefined or null are converted to the empty string. It's right there in the documentation.




              If an element is undefined or null, it is converted to the empty string.







              share|improve this answer



























                5














                5










                5









                Elements of the array that are undefined or null are converted to the empty string. It's right there in the documentation.




                If an element is undefined or null, it is converted to the empty string.







                share|improve this answer













                Elements of the array that are undefined or null are converted to the empty string. It's right there in the documentation.




                If an element is undefined or null, it is converted to the empty string.








                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Mar 28 at 19:32









                PointyPointy

                332k47 gold badges477 silver badges544 bronze badges




                332k47 gold badges477 silver badges544 bronze badges

































                    draft saved

                    draft discarded















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55405532%2fwhy-new-array4-joinha-yields-hahahaha-and-not-undefinedhaundefinedha%23new-answer', 'question_page');

                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

                    SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

                    은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현