javascript - 我在 ubuntu 中学习 js,但是当我给出节点 index.js 的 cmd 时,它将进入新行并忽略第一个 cmd
问题描述
var user = {
firstName: "vishu",
courseCount: 10,
getCourseCount: function () {
console.log("line 7",this);
function sayHello(){
console.log("hello");
console.log("line 10", this);
}
sayHello();
}
}
解决方案
你希望命令做什么?如果您希望它运行您的脚本,它可以。它没有显示任何内容,只是因为您的 js 脚本没有调用任何内容,只是构建了一个对象。
要让它调用您的函数,请尝试
var user = {
firstName: "vishu",
courseCount: 10,
getCourseCount: function () {
console.log("line 7",this);
function sayHello(){
console.log("hello");
console.log("line 10", this);
}
sayHello();
}
}
user.getCourseCount() // add this line to call the function in your user object
推荐阅读
- python - 找出两个数据帧之间的差异
- android - 什么时候应该使用房间缓存和改造缓存?
- javascript - 轮播不显示所有图像?
- maven - Jahia:无法找到请求目标的有效认证路径,并且“parent.relativePath”指向错误的本地 POM
- vb.net - SavePdfFromHtmlStreamToStream 无法获取转换结果标头。数据接收错误。无法接收数据。错误代码:109
- java - 如何定位 td 中的元素和
请帮助通过Java中的文本“所有文档”定位元素
<td ....> <span class="11"> <a onclick= ..... > All documents </a>
如何制作一个可以让我获得
- unreal-engine4 - 如何制作一个可以让我获得 3 个不同随机数的函数 - 蓝图 UE4
- python - 成功导入 OpenCV,但无法正常工作
- python - Python 信号 SIGQUIT 不起作用
- sockets - “tcp/socket”与“tcp/ip”之间的区别