Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

71
Views
Javascript DOM methods are not working after Import Class User.js

User.js

export default class User
{
    constructor()
    {
        this.Name;
        this.Email;
    }
}

index.html

<!DOCTYPE html>
<html lang="en">
<head>
    <title>Document</title>
</head>
<body>
    <div>
        <p>Index Page</p>
        <button onclick="AlertFunction()">Click</button>
    </div>
</body>
<script type="text/javascript" src="index.js"></script>
</html>

index.js

import User from './Modules/User.js';

let thisUser = new User();
thisUser.Name = 'Javascript';
console.log(thisUser.Name);

function AlertFunction()
{
    alert('Alert Clicked');
}

Actual problem: AlertFunction() is not working after the import statement. I want to use class User Type in multiple .js files.

I want to write Util class in Javascript and use it for various files inside my project. I am new to Javascript. Before now I was a .net developer.

In .net we can access all .cs (cSharp files) in the environment. We can access it as a new type for the entire project. We don't need import statements.

But, here in the javascript please help me to understand how import works.

  • How to create a class and use it as a new Type for the entire project. [Pure Javascript]
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!