{"id":19604705,"url":"https://github.com/victorvoid/js4jar","last_synced_at":"2026-02-12T02:04:44.649Z","repository":{"id":89705888,"uuid":"68242583","full_name":"victorvoid/js4jar","owner":"victorvoid","description":"JS for Java Developers :rocket:","archived":false,"fork":false,"pushed_at":"2016-10-13T04:34:15.000Z","size":4,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-26T16:19:42.495Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/victorvoid.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-09-14T20:55:33.000Z","updated_at":"2016-09-21T19:22:19.000Z","dependencies_parsed_at":null,"dependency_job_id":"5a53bea6-8515-49d6-ab9f-d8c13c329683","html_url":"https://github.com/victorvoid/js4jar","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/victorvoid/js4jar","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/victorvoid%2Fjs4jar","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/victorvoid%2Fjs4jar/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/victorvoid%2Fjs4jar/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/victorvoid%2Fjs4jar/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/victorvoid","download_url":"https://codeload.github.com/victorvoid/js4jar/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/victorvoid%2Fjs4jar/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273073423,"owners_count":25040721,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-01T02:00:09.058Z","response_time":120,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-11T09:37:54.391Z","updated_at":"2026-02-12T02:04:39.608Z","avatar_url":"https://github.com/victorvoid.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# JS for Java Developers\n\n- [JavaScript and Java](#javascript-and-java)\n- [Comments](#comments)\n- [Declarations](#declarations)\n  - [Data type conversion](#data-type-conversion)\n- [Literals](#literals)\n  - [Array literals](#array-literals)\n  - [String literals](#string-literals)\n- [Loops](#loops)\n  - [For/in](#for-in)\n- [Methods](#methods)\n  - [Defining and Calling methods](#defining-and-calling-methods)\n- [Classes](#classes)\n  - [Class declarations](#class-declarations)\n  - [Constructor](#constructor)\n  - [Getters and Setters](#getters-and-setters)\n  - [Inheritance](#inheritance)\n\nJavaScript and Java\n-----------------\n\nJavaScript and Java are similar in some ways but fundamentally different in some others. The JavaScript language resembles Java but does not have Java's static typing and strong type checking. JavaScript follows most Java expression syntax, naming conventions and basic control-flow constructs which was the reason why it was renamed from LiveScript to JavaScript.\n\nIn contrast to Java's compile-time system of classes built by declarations, JavaScript supports a runtime system based on a small number of data types representing numeric, Boolean, and string values. JavaScript has a prototype-based object model instead of the more common class-based object model. The prototype-based model provides dynamic inheritance; that is, what is inherited can vary for individual objects. JavaScript also supports functions without any special declarative requirements. Functions can be properties of objects, executing as loosely typed methods.\n\nJavaScript is a very free-form language compared to Java. You do not have to declare all variables, classes, and methods. You do not have to be concerned with whether methods are public, private, or protected, and you do not have to implement interfaces. Variables, parameters, and function return types are not explicitly typed.\n\nJava is a class-based programming language designed for fast execution and type safety. Type safety means, for instance, that you can't cast a Java integer into an object reference or access private memory by corrupting Java bytecodes. Java's class-based model means that programs consist exclusively of classes and their methods. Java's class inheritance and strong typing generally require tightly coupled object hierarchies. These requirements make Java programming more complex than JavaScript programming.\n\nIn contrast, JavaScript descends in spirit from a line of smaller, dynamically typed languages such as HyperTalk and dBASE. These scripting languages offer programming tools to a much wider audience because of their easier syntax, specialized built-in functionality, and minimal requirements for object creation.\n\nFrom [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Introduction#JavaScript_and_Java)\n\nComments\n--------\n\nES5/6/Java\n```js\n// a one line comment\n \n/* this is a longer, \n   multi-line comment\n */\n \n/* You can't, however, /* nest comments */ SyntaxError */\n```\n\nDeclarations\n------------\n\nES5/6 - There are three kinds of declarations in JavaScript.\n\n``var`` - Declares a variable, optionally initializing it to a value.\n\n``let`` - Declares a block scope local variable, optionally initializing it to a value.\n\n``const`` - Declares a read-only named constant.\n\nJava - All variables must have a type. You can use primitive types such as int, float, boolean, etc. Or you can use reference types, such as strings, arrays, or objects.\n\nES5\n```js\n\nvar name = \"Paul\",\n    age  = 19;\n\n```\n\nES6\n```js\n\nlet name = \"Paul\",\n    age  = 19;\n\n```\n\nJava\n```java\n\nString name = \"Paul\";\nint age = 19;\n\n```\n\nData type conversion\n--------------------\n\nES5\n```js\n\nvar name = \"Paul\"\nname = 19;\n//Because JavaScript is dynamically typed, this assignment does not cause an error message.\n```\nJava\n```java\n\nString name = \"Paul\";\nname = 12;\n\n//error: incompatible types: int cannot be converted to String\n```\n\nES5\n\n```js\n\nconsole.log(\"19\" - 9); \n//10\n```\n\nJava\n```java\nSystem.out.println(\"19\" - 9);\n//error: bad operand types for binary operator '-'\n```\n\n## Converting strings to numbers\n\nES5\n```js\n  parseInt(\"15\", 10); // 15 -\u003e you want to use radix 10\n  parseFloat(\"3.14\"); ////floor automatically converts string to number\n```\n\nJava\n```java\n  System.out.println(Integer.parseInt(\"12\")); //12\n  System.out.println(Float.parseFloat(\"15.87\")); //15.87\n```\n\nLiterals\n-------\n\n## Array literals\n\nES5\n```js\n  var powersOfTwo = [1, 2, 4, 8, 16, 32, 64, 128];\n```\nJava\n```java\n  int[] powersOfTwo = {1, 2, 4, 8, 16, 32, 64, 128};\n```\n## String literals\n\nES5\n```js\n \"Hello!\"\n```\nES6\n```js\n// Basic literal string creation\n`In JavaScript '\\n' is a line-feed.`\n\n// Multiline strings\n`In JavaScript this is\n not legal.`\n\n// String interpolation\nvar name = \"Bob\", time = \"today\";\n`Hello ${name}, how are you ${time}?` //Hello Bob, how are you today?\n```\n\nJava\n```java\n \"abc\" is a literal String. \n  \n  String s1 = \"Bob\"; //A String object is an individual instance of the java.lang.String class. \n```\n\nLoops\n------\n\n##For in\n\nES5\n```js\nvar strArray = [\"Victor\", \"Paul\", \"Leona\"];\nfor(myStr in strArray){\n  console.log(strArray[myStr]);\n}\n\n//or\n\nvar strArray = [\"Victor\", \"Paul\", \"Leona\"];\nfor(myStr of strArray){\n  console.log(myStr);\n}\n```\n\nJava\n```java\nString[] strArray= {\"Victor\", \"Paul\", \"Leona\"};\nfor (String myStr : strArray) {\n  System.out.println(myStr);\n}\n```\n\nMethods\n---------\n\n##Defining and Calling methods\nES5\n```js\nvar Person = (function () {\n    function Person(name) {\n        this.name = name;\n    }\n    // Methods\n    Person.prototype.doSomething = function () {\n        console.log(\"I'm a \" + this.name);\n    };\n    return Person;\n})();\n\nvar person1 = new Person(\"Victor Igor\");\nperson1.doSomething();\n```\n\nJava\n```java\nclass Person{\n  String name;\n  void doSomething(){\n    System.out.println(\"I'm a \" + this.name;)\n  }\n}\n```\n\nClasses\n--------\n\n##Class declarations\n\nES5\n\n```js\nfunction Person(){\n  // field, constructor, and \n  // method declarations\n}\n```\n\nES6\n```js\nclass Person {\n  // field, constructor, and \n  // method declarations\n}\n```\n\nJava\n```java\nclass Person {\n  // field, constructor, and \n  // method declarations\n}\n```\n\n##Constructor\n\nES5\n```js\nfunction Person(name, age) {\n  this.name = name;\n  this.age = age;\n}\nvar person = new Person(\"Victor Igor\", 80); //instance\nconsole.log(person.name, person.age);    \n```\n\nES6\n```js\nclass Person {\n  constructor(name, age){\n    this.name = name;\n    this.age  = age;\n  }\n}\nlet person = new Person(\"Victor Igor\", 80);\n```\n\nJava\n```java\nclass Person {\n  String name;\n  int age;\n  Person(String name, int age){\n    this.name = name;\n    this.age  = age;\n  }\n}\n```\n\n##Getters and Setters\n\nES5\n```js\nfunction Person (name, age) {\n  var _name = name;\n  var _age = age;\n  this.setName = function(name) {\n    _name = name;\n  }\n  this.getName = function() {\n      return _name;\n  }\n  this.setAge = function(age){\n    _age = age;\n  }\n  this.getAge = function(){\n    return _age;\n  }\n  \n}\n\n//instantiate the Person class with some arguments\nvar person1 = new Person(\"Victor Igor1\", 80);\nconsole.log(\"Name: \", person1.getName() + \" Age: \" + person1.getAge());\n```\n\nES6\n```js\nclass Person {\n  constructor(name, age) {\n    // Check that (name, age) is a valid date\n    \n    // If it is, use it to initialize \"this\" date's ordinary variables\n    this._name = name;\n    this._age = age;\n  }\n  set name(name){\n     this._name = name;\n  }\n\n  get name() {\n    return this._name;\n  }\n\n  set age(age){\n     this._age = age;\n  }\n\n  get age(){\n    return this._age;\n  }\n}\nlet person1 = new Person(\"Victor Igor\", 20);\nconsole.log(person1.name);\n```\n\nJava\n```java\nclass Person {\n  private String name;\n  private int age;\n  public Person(String name, int age){\n    this.name = name;\n    this.age  = age;\n  }\n  \n  public String getName(){\n    return this.name;\n  }\n  \n  public void setName(name){\n    this.name = name;\n  }\n  \n  public String setAge(age){\n    this.age = age;\n  }\n  \n  public void getAge(age){\n    this.age = age;\n  }\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvictorvoid%2Fjs4jar","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvictorvoid%2Fjs4jar","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvictorvoid%2Fjs4jar/lists"}