Node JS Tutorial for Beginners #4 - The Global Object

Sdílet
Vložit
  • čas přidán 7. 09. 2024
  • Donate via PayPal - www.paypal.me/...
    Donate via Patreon - / thenetninja
    Hey gang, in this Node JS tutorial, I'll introduce you to the global object available to us when using Node JS. The global object, in contrast to the global object in a browser, is not the Window object. It is just an object called 'Global'. In this tutorial we'll take a look at some of the things available to us on the object.
    ----- COURSE LINKS:
    + Repo - github.com/iam...
    + Atom editor - atom.io/
    ---------------------------------------------------------------------------------------------
    You can find more front-end development tutorials on CSS, HTML, JavaScript, jQuery, WordPress & more on the channel homepage...
    SUBSCRIBE TO CHANNEL - / @netninja
    ========== JavaScript for Beginners Playlist ==========
    • JavaScript Tutorials f...
    ============ CSS for Beginners Playlist =============
    • CSS Tutorials For Begi...
    ============== The Net Ninja =====================
    For more front-end development tutorials & to black-belt your coding skills, head over to - / @netninja or thenetninja.co.uk
    ================== Social Links ==================
    Twitter - @TheNetNinja - / thenetninjauk

Komentáře • 127

  • @devinwilcox2153
    @devinwilcox2153 Před 7 lety +5

    Thanks for these. I'm in a bootcamp course that has tried to teach me this, but I feel like my understanding was not sufficient enough for them to teach me how to make a basic node app. It's nice to know there are source videos like this to help me improve my basic understanding of what node is and does. I'll be sharing these with friends.

  • @Priva_C
    @Priva_C Před 6 lety +2

    Your videos are clear and digestible. I sincerely appreciate your time.

  • @manueljordan317
    @manueljordan317 Před 3 lety +1

    Nice videos, shorts and valuable. Even in this 2020, I thought to skip this playlist because was created on 2016. Huge thanks for this playlist!

  • @sodiqayilara1519
    @sodiqayilara1519 Před 3 lety +5

    Very nice video here, but a few clarifications. __filename and __dirname appear to be global but they aren't.
    They are actually parameters of the node wrapper function that wraps all node files behind the scene. keeping all codes in a file scoped within to that wrapper function, hence everything is modular(separated into units). Because these parameters(module,require,exports,__filename,__dirname)are available in all modules, they behave globally, but really they are module-scoped.

    • @itansutarlan9042
      @itansutarlan9042 Před rokem +1

      Indeed, you'll know it when working with the ES module system

  • @alizeaiter478
    @alizeaiter478 Před 7 lety +1

    I love the way you explain things. Other tutorials just type stuff (like __dirname) without explaining where they came from like it's common sense.

  • @FatNonsense
    @FatNonsense Před 7 lety +2

    very nice approach, most other courses don't mention the global object, atleast not at the beginning. I like that!

    • @NetNinja
      @NetNinja  Před 7 lety +1

      Thanks, glad you like :)

  • @mapo5959
    @mapo5959 Před 5 lety +4

    loads of people use nodejs for webdev but I feel like very few people actually understand it and just use the libraries like express etc etc. thanks :)

  • @evaceciliaguillen
    @evaceciliaguillen Před 2 lety

    This is so exitibg!! ! I’ve been Learning Some JS and I think pieces started to make sence now, You make tutorials make sence thankfully!

  • @inurspace
    @inurspace Před 7 lety +2

    Thoroughly enjoying this tutorial, great work.

  • @kingsleyakpan6616
    @kingsleyakpan6616 Před 7 lety +82

    i looooooooooove how short your videos are.

  • @yasinhajilou865
    @yasinhajilou865 Před 6 lety

    hello my teacher i am started node with youre teaching , i hope this tutorial made me node beginner programmer

  • @neetizen5692
    @neetizen5692 Před 5 lety

    even you say this content is tutorial I see more than that you explained clearly, shortly and straight to forward. thanks

  • @infotainment999
    @infotainment999 Před 6 lety +1

    YOU ARE THE BEST TEACHER EVER, and Colt Steele, shout out to Colt, ty!

  • @steffenlaurens8280
    @steffenlaurens8280 Před 6 lety +4

    "We still get that Hey Ninjas because I have not saved this file". XD. Great tutorial video though, your explanation is easy to understand for beginner like me.

  • @youdjparents
    @youdjparents Před 5 lety +2

    thank you for this clear and concise series

  • @manuelverbo1438
    @manuelverbo1438 Před 4 lety

    Your video are the best way to learn fast and focused in.
    Thanks Net Ninja !

  • @j.r.r.tolkien8724
    @j.r.r.tolkien8724 Před 3 měsíci +1

    Correction: __dirname and __filename are not globals. They are local to each file if it's CommonJS. So it won't work with es modules because they are not global keywords.
    PS: Variables that act like globals but are local to each module:
    __dirname
    __filename
    exports
    module
    require()

  • @bharatdussa9588
    @bharatdussa9588 Před 4 lety

    Your video is too easy to understand man! I appreciate your work.

  • @TechNovaAquariums
    @TechNovaAquariums Před 7 lety +2

    Thanks for the awesome tutorials... Can do some PHP (MVC ) tutorials also? I glad that i found this channel.. You and the newboaston guys are awesome

  • @mdalaminmahamud3775
    @mdalaminmahamud3775 Před 6 lety

    no question .. you are awesome... thanks for the documentation based tutorial.. it really helps...

  • @1998charan
    @1998charan Před 6 lety

    Congrats ..for 100k subs and thanks for good tutorials that you provided for free.

  • @romikonlinepotapenko3475
    @romikonlinepotapenko3475 Před 5 lety +3

    Don't want to offend the author, but this particular video (apart from others) is misleading: __filename, __dirname and require() are not on the global object, they are parameters passed into the Module Wrapper function that encapsulates every module (file) in Node:
    console.log(global.__filename); // undefined
    console.log(global.__dirname); // undefined
    console.log(global.require); // undefined

  • @Guitarsey
    @Guitarsey Před 4 lety +9

    I don't know how many have said this but:
    *was that a jojo reference???*

  • @HarryDry
    @HarryDry Před 7 lety +16

    that feeling when your video has 388 upvotes and no downvotes

    • @wobsoriano
      @wobsoriano Před 7 lety +1

      555 and still no downvotes

    • @jorgee557
      @jorgee557 Před 6 lety

      600 :)

    • @wobsoriano
      @wobsoriano Před 6 lety +1

      dude that's amazing

    • @EgYD3m
      @EgYD3m Před 6 lety

      617 and still no dislike i like this MAN :""D

    • @sayedhasancp
      @sayedhasancp Před 6 lety

      now 3 downvotes.......... 1000 upvotes

  • @tomaszwawrowski8089
    @tomaszwawrowski8089 Před 8 lety +6

    Great job! i look forward to next tuts ;)

  • @MegaKurbaa
    @MegaKurbaa Před 6 lety

    Adblocker is off. You are a game changer! Thanks

  • @TheGuroguro12
    @TheGuroguro12 Před 7 lety +3

    Thank you very much so grateful, god bless you.

  • @pepepomada4664
    @pepepomada4664 Před 5 lety +3

    Why the variable "timer" was executed if the function stored inside it was never called? 4:48

    • @kristypolymath1359
      @kristypolymath1359 Před 4 lety +1

      I believe JavaScript has a feature where, a variable can be initialized by calling a function.

  • @engaaaa
    @engaaaa Před 8 měsíci

    fantastic so far, but why do you use characters like () and : ; how do you know what to use and when

  • @sangyeonkim5771
    @sangyeonkim5771 Před 7 lety +3

    This video is very informative! Thank you. XD

  • @chevre
    @chevre Před 3 lety

    node app doesn't work for me it just doesnt do anything
    but when i do node -v it says v14.15.4

  • @Redmile2006
    @Redmile2006 Před 5 lety +1

    I just used clearInterval(this) instead of assigning the return value of setInterval to a var called timer and clearing that. Is there any difference or reason to do it one way or the other?

    • @kristypolymath1359
      @kristypolymath1359 Před 4 lety

      I thought that when you use foo(this), you are acting on the containing object??? But I'm not sure if that containing object is the Global object. Confusing!

  • @lologachupin9207
    @lologachupin9207 Před 4 lety

    Thank you for the video bruh!

  • @leratomphahlele1908
    @leratomphahlele1908 Před 3 lety

    dont know why but atom powershell doesnt recognize node commands even though it correctly installed

  • @jogirajuvegiraju6750
    @jogirajuvegiraju6750 Před 7 lety

    Hi Thanks for the video.Why Settimeinterval function is not completing..? i mean it is running forever printing the second passed. why is it so?

  • @KameshwarSahoo
    @KameshwarSahoo Před 5 lety

    whenever i write a command like console. after dot it shows log and i press enter it comes as console.console.log(), but i don't want console.console i want only console.log() what to do

  • @mohanishsaim9537
    @mohanishsaim9537 Před 2 lety

    how to map array on given condition without using filter function

  • @amazingshortvideos9922

    great tutorial buddy

  • @winnerincrease610
    @winnerincrease610 Před 6 lety

    that feeling when your video has 388 upvotes and no downvotes
    or you mean
    that feeling when your video has 1k upvotes and only 3 downvotes
    whattt

  • @abhinavkant
    @abhinavkant Před 7 lety +1

    5:06 what is the flow of the code and how it is executed by clearInterval() . You didn't explain it.
    can someone explain how it exited from the loop
    ??

    • @aleXelaMec
      @aleXelaMec Před 6 lety

      Abhinav Kant het set if test. Once time == value clearInterval fires

  • @mortenrobinson
    @mortenrobinson Před 4 lety

    4:05 but why is it caught in some sort of a loop? Looking at the code it's not quite clear to me why the looping occurs.

    • @mortenrobinson
      @mortenrobinson Před 4 lety

      Oh... i think i got it. The set interval function itself is looping and keeps calling the function at specified time intervals.

  • @valmanway
    @valmanway Před 4 lety

    Great tutorial mate. I've done a lot of coding on other languages such as c, cpp, java, c# python, haskell and I'm wondering why Javascript developers like writing their callbacks in the parameter and not declare them outside?
    var TIME = 0;
    function counterFunction()
    {
    TIME += 1;
    console.log( time + "sec have passed" );
    if ( TIME > 5 )
    {
    clearInterval( timer );
    }
    };
    var timer = setInterval( counterFunction, 1000 );
    What are the advantages / disadvantages of writing code this way? Purely preference?

    • @sisirpynda5875
      @sisirpynda5875 Před 4 lety

      i think he did that just for demonstration purpose here!

  • @jayn2149
    @jayn2149 Před 6 lety

    @The Net Ninja Wait why didnt you have to invoke the function? it just ran automatically?

  • @ukaszcezary8870
    @ukaszcezary8870 Před 6 lety +1

    Cool that Node is ;)

  • @anlar1998
    @anlar1998 Před 6 lety

    You don't explain everything clearly but i do understand better than other videos that explain it all wtf :D

  • @kingwindie
    @kingwindie Před 7 lety

    what package do you use for autocomplete/suggestion also what theme is that,it's really colorful

  • @brayanmejia6208
    @brayanmejia6208 Před 4 lety

    why each time I write console.log ('hello'); it doesn't pop up on my terminal? despite the file saved as app.js?

    • @abcdefv3917
      @abcdefv3917 Před 3 lety

      is the file path right? is the command right?

  • @MrIshumaru
    @MrIshumaru Před 3 lety

    I personally like this series better the mosh

  • @arpansaini4985
    @arpansaini4985 Před 5 lety

    Awesome work❤

  • @manansoni3942
    @manansoni3942 Před 7 lety

    Hey Man,Great effort by you to teach node to everyone out there.
    I have a question though,why did you write SetInterval in var Timer?

    • @biff9856
      @biff9856 Před 7 lety

      He wrote it in a variable so that he can use that variable to clearInterval further down in the code.

    • @manansoni3942
      @manansoni3942 Před 7 lety

      right...!!!!!
      Thanx bro.

  • @shubhamnegi1937
    @shubhamnegi1937 Před 6 lety

    Did you made the "kung-fu" and the sharp "sword" sound. you created it using audacity or other utility?

  • @anmollipase2056
    @anmollipase2056 Před 5 lety

    Hey...bro...your videos are awesome...but whats the command you said to stop a process in terminal?

  • @TheMdtariq
    @TheMdtariq Před 6 lety

    we can put global objects in variables ? still learning js though.

  • @vzwGrey
    @vzwGrey Před 8 lety +4

    Hey, Net Ninja!
    I've got a very quick question for you: What UI theme and Syntax Theme do you use for Atom and what did you use to have a console inside atom?
    Thanks in advance, and thanks for the amazing tutorials! - EDIT: Just watched your 2nd video in this series and realized you explained how to get the console there, sorry ^^

    • @gokusaiyan1128
      @gokusaiyan1128 Před 7 lety +4

      watch first video , he gave info about his setup

  • @bedashreekashyap3709
    @bedashreekashyap3709 Před 4 lety

    __dirname is not defined in my node. how to fix that?

  • @maxiequa567
    @maxiequa567 Před 8 lety +2

    "setTimeOut is not defined" ?
    and/also you spelt it setTimeout (lowercase 'o') and it still worked??
    setInterval works fine though :)

    • @flammea_
      @flammea_ Před 8 lety +1

      we use lowercase 'o' in vanilla javascript too

    • @TheHTMLCode
      @TheHTMLCode Před 8 lety

      of course setTimeOut is undefined, the function is setTimeout...It's never setTimeOut unless you assign setTimeout to your own function setTimeOut.

    • @maxiequa567
      @maxiequa567 Před 8 lety +2

      Alex Sims inconsistent camel case does my nut bruv :)

  • @yes_cassi
    @yes_cassi Před 6 lety

    great explainer

  • @user-kh6rp6yx1j
    @user-kh6rp6yx1j Před 2 měsíci

    Hey man, good.

  • @paulfrischknecht3999
    @paulfrischknecht3999 Před 6 lety +1

    Nice. But __dirname is not on global. "This variable may appear to be global but is not. See __dirname."

  • @johnfriedrich3706
    @johnfriedrich3706 Před 8 lety +5

    How do you get a PS term in Atom?

    • @valour.se47
      @valour.se47 Před 7 lety +3

      platformio-ide-terminal :)

    • @pbdivyesh
      @pbdivyesh Před 6 lety

      That's because that internal terminal is not actual "cmd" replica but its a "PowerShell" replica showing up there.

  • @melsaied101
    @melsaied101 Před 3 lety

    Thank you

  • @cristalin123
    @cristalin123 Před 5 lety

    Hi there, when you'll make a tutorial about How to read, and how to use Node JS documentation, or NPM , express, or even MDN docs.. for beginners? I've searched a lot on youtube.. and only found one.. about python and mdn but it has been very vague. How to search on them and how to interpret those explanations and examples... it would be very useful. Thanks ! ( P.S if there is someone knowing about what I'm talking about please message me)

  • @vigneshr3236
    @vigneshr3236 Před 3 lety

    should I know Javascript to follow this tutorial?

  • @Revealed7X
    @Revealed7X Před 6 lety

    Uhh, you didn't leave a link to the global documentation :[

  • @PunamSatpute180392
    @PunamSatpute180392 Před 4 lety

    Which editor you are using?

  • @raghupola906
    @raghupola906 Před 6 lety

    __filename and __dirname are not global objects it mentioned Node Documents

  • @GreggRoberts
    @GreggRoberts Před 6 lety

    Node js app uses powershell instead of cmd? Or does that PS mean something else?

    • @pbdivyesh
      @pbdivyesh Před 6 lety

      yeah you are right, that internal terminal is not actual "cmd" replica but its a "PowerShell" replica showing up there.

  • @TheZippydoda123
    @TheZippydoda123 Před 7 lety

    Nothing in the Git Hub for you, shows zero activity?

  • @rakeshdusa3266
    @rakeshdusa3266 Před 6 lety

    what is the tool which you are using please let me know someone

  • @kurzninja
    @kurzninja Před 5 lety

    What's the Atom package you installed to have that built-in console?

  • @alexg7282
    @alexg7282 Před 2 lety

    thx

  • @radhabhawar2714
    @radhabhawar2714 Před 5 lety

    where is the link for globalobject?

  • @arunks8162
    @arunks8162 Před 6 lety

    thanks bro

  • @jasminlord4548
    @jasminlord4548 Před 5 lety

    Where is that link ???

  • @xDanishGamerz
    @xDanishGamerz Před 5 lety

    Its funny, cuz I think that linedin learning (lynda.com) have taking huge inspiration from your tutorial. Yours are free though.

  • @Vickersyt
    @Vickersyt Před 7 lety

    gold

  • @MrMarkgyuro
    @MrMarkgyuro Před 4 lety

    i used only one underscore : )

  • @QkysenQ
    @QkysenQ Před 18 dny

    2:33

  • @respotheme85
    @respotheme85 Před 7 lety

    I am 200 number thumbs up

  • @ManishSharma-yx6om
    @ManishSharma-yx6om Před 7 lety

    which ide do u use??

  • @danilsolodov6120
    @danilsolodov6120 Před 7 lety +2

    why these lessons are in English :( why russians middle or senior level developers doesnt make something like that, English is difficult to understand for me, but I tried) Tnx for these lessons)

    • @user-ob9qo2xh1u
      @user-ob9qo2xh1u Před 6 lety

      Все нормальне по англійськи)

    • @ericbridge8419
      @ericbridge8419 Před 6 lety +2

      Привет! Perhaps yes, understanding English shouldn't be a problem these days. I'm rather having problems understanding Russian xd

  • @sayedhasancp
    @sayedhasancp Před 6 lety

    I like your tutorial but it's too short........... your every video tutorial is with short time.........

  • @rossmanmagnus
    @rossmanmagnus Před 4 lety

    This tutorial is useless since the syntax is different now. You cant just setTimout now

  • @hackdevelopers3449
    @hackdevelopers3449 Před 6 lety

    There is no terminal in my atom