[Solved] Explain the javascript


This looks a bit like minimised code, where function call are often shortened by creating lookup tables, so you can save some bits on long function calls like Element.dispatchEvent and instead minimise it to e[l(p)].

The variable _0x76ed32 holds the reference to your input element.

_0x76ed32['dispatchEvent'](new Event('blur'))

This is a function call on your element. It is equivalent to the usual notation you see:

_0x76ed32.dispatchEvent(new Event('blur'))

meaning it simply dispatches the blur event. This method to write a function call is typical if you don’t know the name of the function and it’s decided at runtime, e.g.

let func="dispatchEvent";
_0x76ed32[func](new Event('blur'))

Look up “reflection” to learn more about this.

The following code snippet is a good example for this:

a0_0x3fed('0x9f')

returns a function name which is then plugged into the following function call

$(_0x76ed32)[a0_0x3fed('0x9f')](a0_0x3fed('0x3b'), _0x5bf4db)

I assume it is setting the value of the input element _0x76ed32, but why the element is being wrapped $(_0x76ed32) and what the two function parameters are, cannot be told from just this line of code.
I assume it’s similar to the native setAttribute(name,value) call.

and lastly you have the following code snippet:

_0x76ed32[a0_0x3fed('0xb3')](new Event('input'))

Here, a0_0x3fed('0xb3') again returns a function name. From inspecting the call, it’s most likely dispatchEvent, which then dispatches the input event on the element _0x76ed32.

It might work something like this:

let _0x76ed32 = document.querySelector("input"),
  fields = {
    '0xb3': "dispatchEvent",
    '0x3b': "value",
    '0x9f': "setAttribute"
  },
  a0_0x3fed = par => fields[par],
  _0x5bf4db = "new value :)";
  
// slightly changed the code
_0x76ed32[a0_0x3fed('0xb3')](new Event('input'));
_0x76ed32[a0_0x3fed('0x9f')](a0_0x3fed('0x3b'), _0x5bf4db);
_0x76ed32[a0_0x3fed('0xb3')](new Event('blur'));
<input type="text" value="old value!" />

Final note: Your code should work perfectly fine, once you emit the events in the right order:

var elem = document.getElementById('mobile');
elem.value="1234567890";
elem.dispatchEvent(new Event('blur', { bubbles: true }));
elem.dispatchEvent(new Event('input', { bubbles: true }));
<input id="mobile" type="text" value="123" />

1

solved Explain the javascript