• 强哥node.js学习笔记


    node后端语言:

    nodejs学习大纲:
    1.node安装
    2.node repl开发
    3.node sublime开发
    4.node 使用
    5.node 中创建第一个应用
    6.node 回调函数
    7.node 事件循环
    8.node event事件
    9.node 模块系统
    10.node 函数
    11.node 路由
    12.node 全局对象
    13.node 文件系统
    14.node get和post请求
    15.node 工具模块
    16.node web模块
    17.html5+js+jsonp+php+node+mysql完成综合项目

    -------------------------------------------------------
    node和js关系:(http://www.techug.com/php-vs-node-js)
    1.php开发简单
    2.node执行简单快

    dos命令:
    start http://www.baidu.com //打开链接
    tasklist //查看进程
    taskkill /f /im chrome.exe //杀死进程
    netstat -ano | find "4445" //查看指定端口

    rpel开发:
    1.执行js代码
    node
    >arr = [1,2,3];
    >console.log(arr);
    2.执行js文件
    node index.js

    node npm安装模块:
    npm list //查看已安装的模块
    npm install mysql //安装mysql模块
    npm uninstall mysql //卸载mysql模块
    npm root //本地模块根目录
    npm root -g //本服务器所有模块根目录
    npm update mysql //升级mysql模块

    node中创建第一个应用(web服务器):
    const http=require('http');
    cs=function (req, res) {
    res.writeHead('200',{'content-type':'text/html;charset=utf-8'});
    res.write('hello world');
    res.end();
    }
    http.createServer(cs).listen(666);
    console.log('http is ok!');

    node回调函数:
    1.同步操作文件(阻塞I/O)
    2.异步操作文件(非阻塞I/O)

    function函数
    1.常用函数
    function show(){}
    2.匿名函数
    show=function(){}

    node路由:

    node全局变量:
    1.__filename
    2.__dirname
    3.setTimeout();
    4.setInterval();
    5.console();
    6.process();

    node常用工具:
    1.util.inspect
    2.util.isArray();
    3.util.isBoolean();
    4.util.isDate();
    5.util.isFunction();
    6.util.isObject();
    7.util.isRegExp();

    node文件系统:
    1.读取文件内容
    异步非阻塞读取readFile();
    同步阻塞读取readFileSync();
    2.写文件内容
    writeFile()
    3.删除文件
    unlink();
    4.创建目录
    mkdir();
    5.删除目录
    rmdir();

    node get和post请求:
    http=require('http');
    url = require('url');
    querystring=require('querystring');
    cs=function (req, res) {
    console.log(req.url);
    uri = req.url;
    if(uri!=='/favicon.ico'){
    str=url.parse(uri).query;
    json=querystring.parse(str);
    console.log(json);
    res.write('this is a web server!');
    res.end();
    }
    }
    http.createServer(cs).listen(8000);
    console.log('http server is ok!');

    os模块:
    1.os.tmpdir();
    2.os.hostname();
    3.os.type();
    4.os.platform();
    5.os.loadavg();
    6.os.totalmem();
    7.os.freemem();
    8.os.cpus();
    9.os.networkInterfaces();

    path模块:
    1.path.dirname();
    2.path.basename();
    3.path.extname();
    4.path.parse();
    5.path.format();

  • 相关阅读:
    js 数据类型的转换
    js数组学习方法汇总
    跳转页面的方法总结
    今天用js做拉一个时钟
    今天用js做拉一个时钟
    js中字符的比较
    1005 继续(3n+1)猜想 (25分)
    1002 写出这个数
    日期差值
    1040 有几个PAT (25分)
  • 原文地址:https://www.cnblogs.com/redheat/p/7069820.html
Copyright © 2020-2023  润新知