GoConqr has a new look! Let us know what you think.

Module 8 of 14 · Text

Important Globals

Tomas Katz

  • console
  • timers (setInterval, setTimeout, clearInterval, clearTimeout)
  • _filename, _dirname (local global, specific to file scope)
    • This variable exists in every files scope, and provide the full path to the file & directory.
  • process
    • process.argv (for command line arguments)
      • When a file is executed using the command line ( for example an NPM start script that passes parameters to an installed package) and passed parameters, these parameters can be accessed inside the file using the process.argv which is an array of strings.
        The first element of the array will be the name of the process running the script, mainly it will be "node".
        The  second element of the array will be the full file path to the script thats executing, for example '/path/to/file/on/your/filesystem/argv.js'.
        The elements following will all be the different arguments passed into the execution command.
        so an example for the returned array from process.argv  will be something like: [ 'node', '/path/to/file/on/your/filesystem/argv.js', 'foo', 'bar', 'bas' ].
        to get only the arguments you can splice the array from the 3rd element to the end of the array.
          
    • process.nextTick (event loop callback)
      • A highly efficient and simple function, that takes a callback function which is added to the start of every event loop Q execution.
        This callback function will always be the first task in an event loop Q execution.
        What important to notice about this function, is that its the first javascript function to execute in every event loop iteration, everything before it is C and everything after it is Javascrpit.
    • stdin - NOTE: RESEARCH
    • stdout - NOTE: RESEARCH
  • Buffer (global class)
    • A globally defined class used to convert data between different types of encoding, for example UTF to ASCII, or ASCII to binary. 
      example:
      var buffer = new Buffer(str, 'utf-8');
      var roundTrip = buffer.toString('utf-8');
  • global - just window object in a browser, can be accessed from anywhere in the application.

 

Instructions

You must submit an attempt for this quiz to progress. You can submit it after the last question.

Go to the chosen module

Feedback

What is it about?

What do you think of the new look?

How do you like it?