[英]How to define a javascript function from Chromium Console
I'm trying to define a Javascript function or a simple variable in Chromium Browser debugger console. 我正在尝试在Chromium Browser调试器控制台中定义Javascript函数或简单变量。 After definition, when I cannot reach this function. 定义后,当我无法达到此功能。 What shall be the problem for it? 它会出现什么问题?
Here are the variable and function definition that I write on the chromium console: 以下是我在chrome控制台上编写的变量和函数定义:
var myvar;
var f = function(){
console.log("Hello world");
};
function f2(){
console.log("Hello world");
};
By the way, I can reach the functions that I created at Mozilla Firefox Browser. 顺便说一句,我可以访问我在Mozilla Firefox浏览器中创建的功能。
What is the problem with Chromium Browser? Chromium Browser有什么问题?
function is reserved word in javascript. 函数是javascript中的保留字。
Try this 试试这个
var f = function() {
console.log("Hello world");
};
instead of 代替
var function = f(){
console.log("Hello world");
};
You can try this: 你可以试试这个:
function fun(a,b)
{
console.log(a,b);
}
fun(5,6); // calling
You can also write 你也可以写
document.myFunc = function(){alert("Hello");}
Call it with 叫它
document.myFunc()
But I'm not an expert 但我不是专家
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.