Node JS Tutorial for Beginners #4 - The Global Object
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
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.
Your videos are clear and digestible. I sincerely appreciate your time.
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!
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.
Indeed, you'll know it when working with the ES module system
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.
very nice approach, most other courses don't mention the global object, atleast not at the beginning. I like that!
Thanks, glad you like :)
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 :)
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!
Thoroughly enjoying this tutorial, great work.
i looooooooooove how short your videos are.
yes small video with good content
hello my teacher i am started node with youre teaching , i hope this tutorial made me node beginner programmer
even you say this content is tutorial I see more than that you explained clearly, shortly and straight to forward. thanks
YOU ARE THE BEST TEACHER EVER, and Colt Steele, shout out to Colt, ty!
"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.
thank you for this clear and concise series
Your video are the best way to learn fast and focused in.
Thanks Net Ninja !
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()
Your video is too easy to understand man! I appreciate your work.
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
no question .. you are awesome... thanks for the documentation based tutorial.. it really helps...
Congrats ..for 100k subs and thanks for good tutorials that you provided for free.
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
I don't know how many have said this but:
*was that a jojo reference???*
My first thought when i saw that lol
that feeling when your video has 388 upvotes and no downvotes
555 and still no downvotes
600 :)
dude that's amazing
617 and still no dislike i like this MAN :""D
now 3 downvotes.......... 1000 upvotes
Great job! i look forward to next tuts ;)
Adblocker is off. You are a game changer! Thanks
Thank you very much so grateful, god bless you.
Thanks for watching :)
Why the variable "timer" was executed if the function stored inside it was never called? 4:48
I believe JavaScript has a feature where, a variable can be initialized by calling a function.
fantastic so far, but why do you use characters like () and : ; how do you know what to use and when
This video is very informative! Thank you. XD
node app doesn't work for me it just doesnt do anything
but when i do node -v it says v14.15.4
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?
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!
Thank you for the video bruh!
dont know why but atom powershell doesnt recognize node commands even though it correctly installed
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?
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
how to map array on given condition without using filter function
great tutorial buddy
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
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
??
Abhinav Kant het set if test. Once time == value clearInterval fires
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.
Oh... i think i got it. The set interval function itself is looping and keeps calling the function at specified time intervals.
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?
i think he did that just for demonstration purpose here!
@The Net Ninja Wait why didnt you have to invoke the function? it just ran automatically?
Cool that Node is ;)
You don't explain everything clearly but i do understand better than other videos that explain it all wtf :D
what package do you use for autocomplete/suggestion also what theme is that,it's really colorful
why each time I write console.log ('hello'); it doesn't pop up on my terminal? despite the file saved as app.js?
is the file path right? is the command right?
I personally like this series better the mosh
Awesome work❤
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?
He wrote it in a variable so that he can use that variable to clearInterval further down in the code.
right...!!!!!
Thanx bro.
Did you made the "kung-fu" and the sharp "sword" sound. you created it using audacity or other utility?
Hey...bro...your videos are awesome...but whats the command you said to stop a process in terminal?
Ctrl+C
@@nanditanayak3303 ok thanks
we can put global objects in variables ? still learning js though.
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 ^^
watch first video , he gave info about his setup
__dirname is not defined in my node. how to fix that?
"setTimeOut is not defined" ?
and/also you spelt it setTimeout (lowercase 'o') and it still worked??
setInterval works fine though :)
we use lowercase 'o' in vanilla javascript too
of course setTimeOut is undefined, the function is setTimeout...It's never setTimeOut unless you assign setTimeout to your own function setTimeOut.
Alex Sims inconsistent camel case does my nut bruv :)
great explainer
Hey man, good.
Hey, thanks!
Nice. But __dirname is not on global. "This variable may appear to be global but is not. See __dirname."
How do you get a PS term in Atom?
platformio-ide-terminal :)
That's because that internal terminal is not actual "cmd" replica but its a "PowerShell" replica showing up there.
Thank you
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)
should I know Javascript to follow this tutorial?
Uhh, you didn't leave a link to the global documentation :[
Which editor you are using?
__filename and __dirname are not global objects it mentioned Node Documents
Node js app uses powershell instead of cmd? Or does that PS mean something else?
yeah you are right, that internal terminal is not actual "cmd" replica but its a "PowerShell" replica showing up there.
Nothing in the Git Hub for you, shows zero activity?
what is the tool which you are using please let me know someone
What's the Atom package you installed to have that built-in console?
platformio-ide-terminal
thx
where is the link for globalobject?
thanks bro
Where is that link ???
Its funny, cuz I think that linedin learning (lynda.com) have taking huge inspiration from your tutorial. Yours are free though.
gold
i used only one underscore : )
2:33
I am 200 number thumbs up
which ide do u use??
Hey, it's called Atom :)
how to get that terminal to work you used to execute
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)
Все нормальне по англійськи)
Привет! Perhaps yes, understanding English shouldn't be a problem these days. I'm rather having problems understanding Russian xd
I like your tutorial but it's too short........... your every video tutorial is with short time.........
This tutorial is useless since the syntax is different now. You cant just setTimout now
There is no terminal in my atom