eval concealing program in JGraph compared to obfuscation and packing

Many times when the topic of eval is brought up, the response is always the same - avoid using eval. However, I believe there is a valid reason for eval to exist. Nevertheless, there are numerous pitfalls to consider.

Regarding jgraph - why do they incorporate eval in this example? Is it sensible to use eval for code concealment, especially when there are obfuscation and packing tools available for JavaScript? Is this the only practical application?

Considering the significant financial stakes involved, I trust they are knowledgeable in their choices.

Answer №1

There is a significant amount of money at stake, so it's safe to say they are knowledgeable about their actions.

Actually, it's not quite effective. This measure is essentially futile when it comes to preventing plagiarism from JavaScript developers. It only adds about 30 seconds to the process of accessing the de-obfuscated code. For example, if I were to visit http://jsFiddle.net or http://jsbin.com and input the following code into the JavaScript box:

var txt = "textContent" in document.body ? "textContent" : "innerText",
    eval = function (s) { document.body[txt] = s; }

Then, I could simply copy and paste the code from that site into the fiddle and run it. This would display all the code on the page, allowing me to copy and paste it into . There are various other methods to extract the code as well. One could easily copy and paste the string into any developer tools console window to get the desired output.

While obfuscation serves a purpose, implementing an additional layer using eval seems amateurish and signifies a desperate attempt to conceal their valuable source code. This practice does not demonstrate expertise on their part.

Answer №2

Utilizing eval opens up a plethora of possibilities! There are instances where it may be the only solution.

However:

  • Code executed with eval may be slower
  • Debugging errors in evaluated code can be difficult without line numbers
  • Overusing eval can lead to unreadable code

Here's an example of something that would be challenging to achieve without eval:

var varname = "X";
var varvalue = 5;
eval("var "+varname+" = "+varvalue+";");
console.log(X);

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

`Monitoring and adjusting page view during window resizing in a dynamic website`

Situation: Imagine we are reading content on a responsive page and decide to resize the browser window. As the window narrows, the content above extends down, making the entire page longer. This results in whatever content we were previously viewing bein ...

Generate a dynamic file import loop within a React application

Suppose I have a directory containing several .md files: /static/blog/ example_title.md another_example.md three_examples.md and an array that includes all the titles: const blogEntries = ["example_title", "another_example", "three_examples"] In ...

Is there a way for me to retrieve the pageProbs that I have shared with a Component in _app.js?

Upon the loading of my website, I am fetching a large amount of data using getInitialProps. MyApp.getInitialProps = async (appContext) => { // Calls page's `getInitialProps` and fills `appProps.pageProps` const appProps = await App.getInitialProps( ...

In JavaScript, the task involves filtering through multiple arrays of objects to calculate the average value based on the contract number

Every object in the Array contains a contractNumber, but with repeated values. I am attempting to determine the average value of each unique contractNumber. var vendorArr=[{ "contractNumber":5258, "monthId":0, "value":2}, { ...

Unable to find the desired match with Regex

I'm attempting to use a regex to replace content within brackets, but I'm encountering an unexpected result. This is the text I'm trying to target: Foo (bar) Below is the regex pattern I am using: /(?=\().*(?=\))/ My expectati ...

In Javascript, what significance does the symbol ":" hold?

While exploring the Ionic framework, I came across the following code snippet: import { AlertController } from 'ionic-angular'; export class MyPage { constructor(public alertCtrl: AlertController) { } I'm curious about the significanc ...

Utilizing Node and Express to transform an array into a "Object" Map

For my latest project, I decided to build a web application using Node Express for the backend and Vue for the front end. While working on it, I encountered an issue where an array in an object was being converted to a map when sent to Express via jQuery. ...

Error message: Unchecked runtime error - Unable to retrieve data from the specified URL. The extension manifest must include permission to access this particular host. This issue is occurring in manifest

Can someone help me out? I keep on receiving the error messages Unchecked runtime.lastError: Cannot access contents of url. Extension manifest must request permission to access this host. and Unchecked runtime.lastError: Could not establish connection. Rec ...

A guide on using jQuery to iterate through 3 separate div elements

Seeking assistance with creating a dynamic loop for multiple divs (3 or more) using jQuery. The desired outcome is to have the main image div on the homepage rotate with other divs, changing both the background image and links within each div. I initially ...

Retrieve the database value for the chosen name and then add that name to a different table

I am working on a dropdown feature that fetches categories from a database and displays the selected category price in a textfield. For example, when 'web development' is selected, the price ($12) will display in the textfield. Below is the cod ...

Numerous HTML documents being uploaded to the server for a multitude of individuals

Currently, I am developing a game on a website where players create new rooms and are assigned specific roles with individual powers. Some players need to wait for input from others, creating a dynamic gameplay experience. Additionally, there are certain ...

Retrieving information from JSON files related to table objects

How to Display JSON data in a Table? I am facing difficulty accessing my JSON data as it is nested within an array of objects. How can I retrieve this information? Currently, I am using the map function to display only the name and avatar, but the data s ...

Steps for Implementing a Delay on Bootstrap Dropdown Hover

Is there a way to create a delay for the bootstrap dropdown feature while ensuring that it still appears on hover? If you want to test this, click here: http://www.bootply.com/YcVBzvXqrR This is the HTML code I'm using: <div class="container"&g ...

What is the best way to handle an AJAX JSON response in AngularJS?

Need help with extracting properties from a JSON object returned by a REST service in AngularJS? Want to parse the firstName, lastName, and other attributes from the JSON response? Check out the code snippets below for guidance. Here is an example of an A ...

Leverage the power of Angular's library dependency injection with the @inject

I am currently working on a project that involves a library. Within one of the classes in this library, I am attempting to provide a service using @optional, @host, and @inject decorators with an injection token. In the parent component, I have the optio ...

Achieve seamless integration of PHP function execution with Javascript onClick without the need for page

After delving into my research, it seems like Ajax and/or JQuery may be the way to go for what I'm trying to achieve. However, I wanted to double-check before moving forward in that direction. The task at hand involves using a javascript onclick func ...

Create a customizable table without relying on external jQuery plugins

Looking to develop a table with editable content (using an "edit" button on each row) without relying on Bootstrap or any additional plugins. The goal is to utilize HTML, PHP, AJAX, and JavaScript exclusively for this task. Can anyone provide guidance, sam ...

Exploring the usage of multidimensional arrays in React components

How can I extract data such as teamId from the "teams" array using datas.map() method in a multidimensional array? Any tips or help would be appreciated. Is there another way to map out this data? { "gameId": 3226262256, "platformId": "NA1", " ...

What may be causing my Ajax call to get stuck at readystate 1 and not progress further

I've double-checked all my code, yet I'm not getting any response from my Ajax call. Can someone help me figure out what's wrong? function fetchPokemonData() { const apiRequest = new XMLHttpRequest(); apiRequest.open('GET', &apo ...

Creating reactive data in a Vue.js 2 component

I'm currently learning Vue.js 2. I encountered an issue with my code while receiving dynamic data from a server (using Laravel 5.3). The problem arises when I attempt to declare the users array within the component instead of declaring it in the Vue() ...