Nodejs>------->> Chapter III: node. JS Basics

Source: Internet
Author: User

Chapter III: The basic knowledge of node. js

One: Console 1:console.log, Console.info Method in node. js

  1 console.log ("This isa test string.");

  1 node app1.js 1> info.log

1Console.log ("This is a test String.");2 3 //Start with the second argument and output all the strings sequentially4Console.log ("%s","Hoge","Foo");//output is Hoge foo5 //Convert object to string after output6Console.log ("%s","Hoge", {foo:"FOO"});//Output result is Hoge ({foo:foo})7 //Converts a value to a string output, starting with the second argument, outputting all values sequentially8Console.log ("%d", 10,12,14,15,15.5);//Output result is 10,12,14,15,15.59 //Convert string as numeric value, Output NanTenConsole.log ("%d","Hoge");//Output Nan One //Output percent sign AConsole.log ("%%","Hoge");//output% Hoge

1Console.log (" the");//using operator, output is 42Console.log (2/0);//Output Infinity3 4 varA=1;5 varb=2;6 //calculation of the value variable A + value variable b results in output7Console.log (A+B);//Output result is 38 After converting a numeric variable A to a string, use the + operation symbol to concatenate 2 strings after the output9Console.log (A.toString() +b.toString());//output result isTen  One varA=1; A vard=t; -Console.log (A==B);//Use comparison operator, output false -Console.log (a==1&&b==2);//Use logical operator, output true



2:console.error, Console.warn method

App1.js

  1  console.error ("This isanerror  ");

The result of the operation is:

  1 node app1.js 2> error.log

  1 node script.js 2> error.log

1module.js:4712     ThrowErr3^4 5Error:cannotFindModule ' i:\ Learning materials \node.js authoritative guide \ Source code \chapter3\ codes List 3-1\script.js '6AtFunction. Module._resolvefilename (module.js:469:15)7AtFunction. Module._load (MODULE.JS:417:25)8At Module.runmain (module.js:604:10)9At Run (bootstrap_node.js:389:7)TenAt startup (Bootstrap_node.js:149:9) OneAt Bootstrap_node.js:502:3 A 


3:console.dir method

Nodejs>------->> Chapter III: node. JS Basics

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.