Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.

?
Lv 4

Javascript, why do I get this error?

This is the code

function preloader() {

"use strict";

var heavyImage = new Image();

heavyImage.src = "heavyimagefile.jpg";

}

This is the error.

Problem at line 3 character 26: 'Image' was used before it was defined.

2 Answers

Relevance
  • t
    Lv 5
    9 years ago
    Favorite Answer

    Works in my browser's JavaScript interpreter (except for URL not found error).

    How are you running it? What's the 2nd line for? It doesn't have any effect. If you are trying to write a comment, it's done like this:

    //use strict

  • ?
    Lv 5
    9 years ago

    write that line code as "Image var heavyImage = new Image()";// image is a object before using to you have to initialize it.

Still have questions? Get your answers by asking now.