Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/75.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript数组和对象程序未执行?Google开发者工具上的控制台显示“Google开发者工具”;未捕获的语法错误:意外标记';{';_Javascript_Html_Arrays_Object_Developer Tools - Fatal编程技术网

Javascript数组和对象程序未执行?Google开发者工具上的控制台显示“Google开发者工具”;未捕获的语法错误:意外标记';{';

Javascript数组和对象程序未执行?Google开发者工具上的控制台显示“Google开发者工具”;未捕获的语法错误:意外标记';{';,javascript,html,arrays,object,developer-tools,Javascript,Html,Arrays,Object,Developer Tools,我收到一个错误作为未捕获的语法错误:意外的标记“{” 以下是我编写的Javascript代码- var database= [ { username:"Kevin", password:"Robotboy" } ]; var newsFeed= [ { username:"David", timeline:"It's an eye opening thought!" }, { username:"Kane", timeline:"Wh

我收到一个错误作为未捕获的语法错误:意外的标记“{”

以下是我编写的Javascript代码-

var database=
[
 {
    username:"Kevin",
    password:"Robotboy"
 }
];

var newsFeed=
[
 {
    username:"David",
    timeline:"It's an eye opening thought!"
 },

 {
    username:"Kane",
    timeline:"What a wonderful day!"
 }
];

var userNamePrompt=prompt("What is your username?");
var passwordPrompt=prompt("What is your password?");

function signIn(user,pass)
{
    if(user===database[0].username && pass===database[0].password)
    {
        console.log(newsFeed);
    }
    else
    {
        alert("ERR, no such account exists!");
    }
}
这是HTML代码-

<!DOCTYPE html>
<head>
    <title>Facebook Test</title>
</head>
<body>
<script type="text/javascript" src="D:\Coding\Html\Learn\newweb\newjavascript\December19\socialsite.js"></script>
</body>
</html>

Facebook测试

让我知道出现这种情况的原因?

您的代码似乎工作正常(如果您调用
signIn()
),您可以添加GDT发现此错误的行吗?请不要在客户端执行身份验证。@NickParsons问题已解决!感谢您的时间!@KarulessWhisper问题已解决,感谢您的时间。