Convert 2 bytes in a buffer to integer

thank you for the reply.

I solved the problem in another way.

I solved it as below.

var pay2=Buffer.alloc(2);
pay2[0]=msg.payload[3];
pay2[1]=msg.payload[4];
var pay3=pay2.slice(0,4).toString('hex');
var pay4=Number("0x"+pay3);